-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp2.cpp | 4 |
3 files changed, 15 insertions, 19 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index a7b0bdc..650e634 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -1,793 +1,785 @@ | |||
1 | 1 | ||
2 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
3 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | #include "interfacesetupimp.h" | 5 | #include "interfacesetupimp.h" |
6 | #include "interfaces.h" | 6 | #include "interfaces.h" |
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <opie2/oprocess.h> | 11 | #include <opie2/oprocess.h> |
12 | #include <opie2/oresource.h> | ||
13 | |||
12 | #include <qpe/applnk.h> | 14 | #include <qpe/applnk.h> |
13 | #include <qpe/qcopenvelope_qws.h> | 15 | #include <qpe/qcopenvelope_qws.h> |
14 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
16 | #include <qpe/qlibrary.h> | 18 | #include <qpe/qlibrary.h> |
17 | #include <qpe/resource.h> | ||
18 | 19 | ||
19 | /* QT */ | 20 | /* QT */ |
20 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
21 | #include <qlistbox.h> | 22 | #include <qlistbox.h> |
22 | #include <qlineedit.h> | 23 | #include <qlineedit.h> |
23 | #include <qlistview.h> | 24 | #include <qlistview.h> |
24 | #include <qheader.h> | 25 | #include <qheader.h> |
25 | #include <qlabel.h> | 26 | #include <qlabel.h> |
26 | #include <qtabwidget.h> // in order to disable the profiles tab | 27 | #include <qtabwidget.h> // in order to disable the profiles tab |
27 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
28 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
29 | #include <qregexp.h> | 30 | #include <qregexp.h> |
30 | 31 | ||
31 | 32 | ||
32 | #if QT_VERSION < 0x030000 | 33 | #if QT_VERSION < 0x030000 |
33 | #include <qlist.h> | 34 | #include <qlist.h> |
34 | #else | 35 | #else |
35 | #include <qptrlist.h> | 36 | #include <qptrlist.h> |
36 | #endif | 37 | #endif |
37 | #include <qdir.h> | 38 | #include <qdir.h> |
38 | #include <qfile.h> | 39 | #include <qfile.h> |
39 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
40 | #include <qregexp.h> | 41 | #include <qregexp.h> |
41 | 42 | ||
42 | /* STD */ | 43 | /* STD */ |
43 | #include <net/if.h> | 44 | #include <net/if.h> |
44 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
45 | #include <sys/socket.h> | 46 | #include <sys/socket.h> |
46 | 47 | ||
47 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 48 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
48 | #define _PROCNETDEV "/proc/net/dev" | 49 | #define _PROCNETDEV "/proc/net/dev" |
49 | 50 | ||
50 | // is this always right? | 51 | // is this always right? |
51 | #define _HOSTFILE "/etc/hostname" | 52 | #define _HOSTFILE "/etc/hostname" |
52 | #define _IRDANAME "/proc/sys/net/irda/devname" | 53 | #define _IRDANAME "/proc/sys/net/irda/devname" |
53 | 54 | ||
54 | using namespace Opie::Core; | 55 | using namespace Opie::Core; |
55 | 56 | ||
56 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 57 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
57 | { | 58 | { |
58 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 59 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
59 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 60 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
60 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 61 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
61 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 62 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
62 | 63 | ||
63 | //remove tab with no function | 64 | //remove tab with no function |
64 | tabWidget->removePage( tab ); | 65 | tabWidget->removePage( tab ); |
65 | 66 | ||
66 | // Load connections. | 67 | // Load connections. |
67 | // /usr/local/kde/lib/libinterfaces.la | 68 | // /usr/local/kde/lib/libinterfaces.la |
68 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 69 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
69 | getAllInterfaces(); | 70 | getAllInterfaces(); |
70 | 71 | ||
71 | Interfaces i; | 72 | Interfaces i; |
72 | QStringList list = i.getInterfaceList(); | 73 | QStringList list = i.getInterfaceList(); |
73 | QMap<QString, Interface*>::Iterator it; | 74 | QMap<QString, Interface*>::Iterator it; |
74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) | 75 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
75 | { | 76 | { |
76 | /* | 77 | /* |
77 | * we skipped it in getAllInterfaces now | 78 | * we skipped it in getAllInterfaces now |
78 | * we need to ignore it as well | 79 | * we need to ignore it as well |
79 | */ | 80 | */ |
80 | if (m_handledIfaces.contains( *ni) ) | 81 | if (m_handledIfaces.contains( *ni) ) |
81 | { | 82 | { |
82 | odebug << "Not up iface handled by module" << oendl; | 83 | odebug << "Not up iface handled by module" << oendl; |
83 | continue; | 84 | continue; |
84 | } | 85 | } |
85 | bool found = false; | 86 | bool found = false; |
86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) | 87 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
87 | { | 88 | { |
88 | if(it.key() == (*ni)) | 89 | if(it.key() == (*ni)) |
89 | found = true; | 90 | found = true; |
90 | } | 91 | } |
91 | if(!found) | 92 | if(!found) |
92 | { | 93 | { |
93 | if(!(*ni).contains("_")) | 94 | if(!(*ni).contains("_")) |
94 | { | 95 | { |
95 | Interface *i = new Interface(this, *ni, false); | 96 | Interface *i = new Interface(this, *ni, false); |
96 | i->setAttached(false); | 97 | i->setAttached(false); |
97 | i->setHardwareName(tr("Disconnected")); | 98 | i->setHardwareName(tr("Disconnected")); |
98 | interfaceNames.insert(i->getInterfaceName(), i); | 99 | interfaceNames.insert(i->getInterfaceName(), i); |
99 | updateInterface(i); | 100 | updateInterface(i); |
100 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); | 101 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
101 | } | 102 | } |
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
105 | //getInterfaceList(); | 106 | //getInterfaceList(); |
106 | connectionList->header()->hide(); | 107 | connectionList->header()->hide(); |
107 | 108 | ||
108 | Config cfg("NetworkSetup"); | 109 | Config cfg("NetworkSetup"); |
109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 110 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
110 | for ( QStringList::Iterator it = profiles.begin(); | 111 | for ( QStringList::Iterator it = profiles.begin(); |
111 | it != profiles.end(); ++it) | 112 | it != profiles.end(); ++it) |
112 | profilesList->insertItem((*it)); | 113 | profilesList->insertItem((*it)); |
113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 114 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 115 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 116 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
116 | 117 | ||
117 | QFile file(scheme); | 118 | QFile file(scheme); |
118 | if ( file.open(IO_ReadOnly) ) | 119 | if ( file.open(IO_ReadOnly) ) |
119 | { // file opened successfully | 120 | { // file opened successfully |
120 | QTextStream stream( &file ); // use a text stream | 121 | QTextStream stream( &file ); // use a text stream |
121 | while ( !stream.eof() ) | 122 | while ( !stream.eof() ) |
122 | { // until end of file... | 123 | { // until end of file... |
123 | QString line = stream.readLine(); // line of text excluding '\n' | 124 | QString line = stream.readLine(); // line of text excluding '\n' |
124 | if(line.contains("SCHEME")) | 125 | if(line.contains("SCHEME")) |
125 | { | 126 | { |
126 | line = line.mid(7, line.length()); | 127 | line = line.mid(7, line.length()); |
127 | currentProfileLabel->setText(line); | 128 | currentProfileLabel->setText(line); |
128 | break; | 129 | break; |
129 | } | 130 | } |
130 | } | 131 | } |
131 | file.close(); | 132 | file.close(); |
132 | } | 133 | } |
133 | makeChannel(); | 134 | makeChannel(); |
134 | initHostname(); | 135 | initHostname(); |
135 | } | 136 | } |
136 | 137 | ||
137 | /** | 138 | /** |
138 | * Deconstructor. Save profiles. Delete loaded libraries. | 139 | * Deconstructor. Save profiles. Delete loaded libraries. |
139 | */ | 140 | */ |
140 | MainWindowImp::~MainWindowImp() | 141 | MainWindowImp::~MainWindowImp() |
141 | { | 142 | { |
142 | // Save profiles. | 143 | // Save profiles. |
143 | Config cfg("NetworkSetup"); | 144 | Config cfg("NetworkSetup"); |
144 | cfg.setGroup("General"); | 145 | cfg.setGroup("General"); |
145 | cfg.writeEntry("Profiles", profiles.join(" ")); | 146 | cfg.writeEntry("Profiles", profiles.join(" ")); |
146 | 147 | ||
147 | // Delete all interfaces that don't have owners. | 148 | // Delete all interfaces that don't have owners. |
148 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 149 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
149 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 150 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
150 | { | 151 | { |
151 | if(iIt.key()->getModuleOwner() == NULL) | 152 | if(iIt.key()->getModuleOwner() == NULL) |
152 | delete iIt.key(); | 153 | delete iIt.key(); |
153 | } | 154 | } |
154 | 155 | ||
155 | // Delete Modules and Libraries | 156 | // Delete Modules and Libraries |
156 | QMap<Module*, QLibrary*>::Iterator it; | 157 | QMap<Module*, QLibrary*>::Iterator it; |
157 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 158 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
158 | { | 159 | { |
159 | delete it.key(); | 160 | delete it.key(); |
160 | // I wonder why I can't delete the libraries | 161 | // I wonder why I can't delete the libraries |
161 | // What fucking shit this is. | 162 | // What fucking shit this is. |
162 | //delete it.data(); | 163 | //delete it.data(); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | 166 | ||
166 | /** | 167 | /** |
167 | * Query the kernel for all of the interfaces. | 168 | * Query the kernel for all of the interfaces. |
168 | */ | 169 | */ |
169 | void MainWindowImp::getAllInterfaces() | 170 | void MainWindowImp::getAllInterfaces() |
170 | { | 171 | { |
171 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 172 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
172 | if(sockfd == -1) | 173 | if(sockfd == -1) |
173 | return; | 174 | return; |
174 | 175 | ||
175 | struct ifreq ifr; | 176 | struct ifreq ifr; |
176 | QStringList ifaces; | 177 | QStringList ifaces; |
177 | QFile procFile(QString(_PROCNETDEV)); | 178 | QFile procFile(QString(_PROCNETDEV)); |
178 | int result; | 179 | int result; |
179 | Interface *i; | 180 | Interface *i; |
180 | 181 | ||
181 | if (! procFile.exists()) | 182 | if (! procFile.exists()) |
182 | { | 183 | { |
183 | struct ifreq ifrs[100]; | 184 | struct ifreq ifrs[100]; |
184 | struct ifconf ifc; | 185 | struct ifconf ifc; |
185 | ifc.ifc_len = sizeof(ifrs); | 186 | ifc.ifc_len = sizeof(ifrs); |
186 | ifc.ifc_req = ifrs; | 187 | ifc.ifc_req = ifrs; |
187 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 188 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
188 | 189 | ||
189 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) | 190 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) |
190 | { | 191 | { |
191 | struct ifreq *pifr = &ifrs[i]; | 192 | struct ifreq *pifr = &ifrs[i]; |
192 | if ( !QString( pifr->ifr_name ).startsWith( "wifi" ) ) ifaces += pifr->ifr_name; | 193 | if ( !QString( pifr->ifr_name ).startsWith( "wifi" ) ) ifaces += pifr->ifr_name; |
193 | else odebug << "ignoring hostap control interface " << pifr->ifr_name << oendl; | 194 | else odebug << "ignoring hostap control interface " << pifr->ifr_name << oendl; |
194 | } | 195 | } |
195 | } | 196 | } |
196 | else | 197 | else |
197 | { | 198 | { |
198 | procFile.open(IO_ReadOnly); | 199 | procFile.open(IO_ReadOnly); |
199 | QString line; | 200 | QString line; |
200 | QTextStream procTs(&procFile); | 201 | QTextStream procTs(&procFile); |
201 | int loc = -1; | 202 | int loc = -1; |
202 | 203 | ||
203 | procTs.readLine(); // eat a line | 204 | procTs.readLine(); // eat a line |
204 | procTs.readLine(); // eat a line | 205 | procTs.readLine(); // eat a line |
205 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) | 206 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
206 | { | 207 | { |
207 | if((loc = line.find(":")) != -1) | 208 | if((loc = line.find(":")) != -1) |
208 | { | 209 | { |
209 | // ignore wifi* (hostap control interfaces) | 210 | // ignore wifi* (hostap control interfaces) |
210 | if ( !line.left(loc).startsWith( "wifi" ) ) ifaces += line.left(loc); | 211 | if ( !line.left(loc).startsWith( "wifi" ) ) ifaces += line.left(loc); |
211 | else odebug << "ignoring hostap control interface " << line.left(loc) << oendl; | 212 | else odebug << "ignoring hostap control interface " << line.left(loc) << oendl; |
212 | } | 213 | } |
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
216 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
217 | { | 218 | { |
218 | int flags = 0; | 219 | int flags = 0; |
219 | if ( m_handledIfaces.contains( (*it) ) ) | 220 | if ( m_handledIfaces.contains( (*it) ) ) |
220 | { | 221 | { |
221 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; | 222 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; |
222 | continue; | 223 | continue; |
223 | } | 224 | } |
224 | // int family; | 225 | // int family; |
225 | i = NULL; | 226 | i = NULL; |
226 | 227 | ||
227 | strcpy(ifr.ifr_name, (*it).latin1()); | 228 | strcpy(ifr.ifr_name, (*it).latin1()); |
228 | 229 | ||
229 | struct ifreq ifcopy; | 230 | struct ifreq ifcopy; |
230 | ifcopy = ifr; | 231 | ifcopy = ifr; |
231 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
232 | flags = ifcopy.ifr_flags; | 233 | flags = ifcopy.ifr_flags; |
233 | i = new Interface(this, ifr.ifr_name, false); | 234 | i = new Interface(this, ifr.ifr_name, false); |
234 | i->setAttached(true); | 235 | i->setAttached(true); |
235 | if ((flags & IFF_UP) == IFF_UP) | 236 | if ((flags & IFF_UP) == IFF_UP) |
236 | i->setStatus(true); | 237 | i->setStatus(true); |
237 | else | 238 | else |
238 | i->setStatus(false); | 239 | i->setStatus(false); |
239 | 240 | ||
240 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
241 | i->setHardwareName("Ethernet"); | 242 | i->setHardwareName("Ethernet"); |
242 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
243 | i->setHardwareName("Point to Point"); | 244 | i->setHardwareName("Point to Point"); |
244 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
245 | i->setHardwareName("Multicast"); | 246 | i->setHardwareName("Multicast"); |
246 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
247 | i->setHardwareName("Loopback"); | 248 | i->setHardwareName("Loopback"); |
248 | else | 249 | else |
249 | i->setHardwareName("Unknown"); | 250 | i->setHardwareName("Unknown"); |
250 | 251 | ||
251 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; | 252 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; |
252 | interfaceNames.insert(i->getInterfaceName(), i); | 253 | interfaceNames.insert(i->getInterfaceName(), i); |
253 | updateInterface(i); | 254 | updateInterface(i); |
254 | connect(i, SIGNAL(updateInterface(Interface*)), | 255 | connect(i, SIGNAL(updateInterface(Interface*)), |
255 | this, SLOT(updateInterface(Interface*))); | 256 | this, SLOT(updateInterface(Interface*))); |
256 | } | 257 | } |
257 | // now lets ask the plugins too ;) | 258 | // now lets ask the plugins too ;) |
258 | QMap<Module*, QLibrary*>::Iterator it; | 259 | QMap<Module*, QLibrary*>::Iterator it; |
259 | QList<Interface> ilist; | 260 | QList<Interface> ilist; |
260 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 261 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
261 | { | 262 | { |
262 | if(it.key()) | 263 | if(it.key()) |
263 | { | 264 | { |
264 | ilist = it.key()->getInterfaces(); | 265 | ilist = it.key()->getInterfaces(); |
265 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 266 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
266 | { | 267 | { |
267 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; | 268 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; |
268 | interfaceNames.insert(i->getInterfaceName(), i); | 269 | interfaceNames.insert(i->getInterfaceName(), i); |
269 | updateInterface(i); | 270 | updateInterface(i); |
270 | connect(i, SIGNAL(updateInterface(Interface*)), | 271 | connect(i, SIGNAL(updateInterface(Interface*)), |
271 | this, SLOT(updateInterface(Interface*))); | 272 | this, SLOT(updateInterface(Interface*))); |
272 | } | 273 | } |
273 | } | 274 | } |
274 | } | 275 | } |
275 | } | 276 | } |
276 | 277 | ||
277 | /** | 278 | /** |
278 | * Load all modules that are found in the path | 279 | * Load all modules that are found in the path |
279 | * @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 |
280 | * and attempts to load them | 281 | * and attempts to load them |
281 | */ | 282 | */ |
282 | void MainWindowImp::loadModules(const QString &path) | 283 | void MainWindowImp::loadModules(const QString &path) |
283 | { | 284 | { |
284 | #ifdef DEBUG | 285 | #ifdef DEBUG |
285 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; | 286 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; |
286 | #endif | 287 | #endif |
287 | QDir d(path); | 288 | QDir d(path); |
288 | if(!d.exists()) | 289 | if(!d.exists()) |
289 | return; | 290 | return; |
290 | 291 | ||
291 | QString lang = ::getenv("LANG"); | 292 | QString lang = ::getenv("LANG"); |
292 | // Don't want sym links | 293 | // Don't want sym links |
293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 294 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
294 | const QFileInfoList *list = d.entryInfoList(); | 295 | const QFileInfoList *list = d.entryInfoList(); |
295 | QFileInfoListIterator it( *list ); | 296 | QFileInfoListIterator it( *list ); |
296 | QFileInfo *fi; | 297 | QFileInfo *fi; |
297 | while ( (fi=it.current()) ) | 298 | while ( (fi=it.current()) ) |
298 | { | 299 | { |
299 | if(fi->fileName().contains(".so")) | 300 | if(fi->fileName().contains(".so")) |
300 | { | 301 | { |
301 | /* if loaded install translation */ | 302 | /* if loaded install translation */ |
302 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ | 303 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ |
303 | QTranslator *trans = new QTranslator(qApp); | 304 | QTranslator *trans = new QTranslator(qApp); |
304 | QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; | 305 | QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; |
305 | if( trans->load( fn ) ) | 306 | if( trans->load( fn ) ) |
306 | qApp->installTranslator( trans ); | 307 | qApp->installTranslator( trans ); |
307 | else | 308 | else |
308 | delete trans; | 309 | delete trans; |
309 | } | 310 | } |
310 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; | 311 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; |
311 | } | 312 | } |
312 | ++it; | 313 | ++it; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | 316 | ||
316 | /** | 317 | /** |
317 | * Attempt to load a function and resolve a function. | 318 | * Attempt to load a function and resolve a function. |
318 | * @param pluginFileName - the name of the file in which to attempt to load | 319 | * @param pluginFileName - the name of the file in which to attempt to load |
319 | * @param resolveString - function pointer to resolve | 320 | * @param resolveString - function pointer to resolve |
320 | * @return pointer to the function with name resolveString or NULL | 321 | * @return pointer to the function with name resolveString or NULL |
321 | */ | 322 | */ |
322 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 323 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
323 | { | 324 | { |
324 | #ifdef DEBUG | 325 | #ifdef DEBUG |
325 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; | 326 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; |
326 | #endif | 327 | #endif |
327 | QLibrary *lib = new QLibrary(pluginFileName); | 328 | QLibrary *lib = new QLibrary(pluginFileName); |
328 | void *functionPointer = lib->resolve(resolveString); | 329 | void *functionPointer = lib->resolve(resolveString); |
329 | if( !functionPointer ) | 330 | if( !functionPointer ) |
330 | { | 331 | { |
331 | #ifdef DEBUG | 332 | #ifdef DEBUG |
332 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; | 333 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; |
333 | #endif | 334 | #endif |
334 | delete lib; | 335 | delete lib; |
335 | return 0; | 336 | return 0; |
336 | } | 337 | } |
337 | // Try to get an object. | 338 | // Try to get an object. |
338 | Module *object = ((Module* (*)()) functionPointer)(); | 339 | Module *object = ((Module* (*)()) functionPointer)(); |
339 | if(object == 0) | 340 | if(object == 0) |
340 | { | 341 | { |
341 | #ifdef DEBUG | 342 | #ifdef DEBUG |
342 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; | 343 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; |
343 | #endif | 344 | #endif |
344 | delete lib; | 345 | delete lib; |
345 | return 0; | 346 | return 0; |
346 | } | 347 | } |
347 | 348 | ||
348 | m_handledIfaces += object->handledInterfaceNames(); | 349 | m_handledIfaces += object->handledInterfaceNames(); |
349 | // Store for deletion later | 350 | // Store for deletion later |
350 | libraries.insert(object, lib); | 351 | libraries.insert(object, lib); |
351 | return object; | 352 | return object; |
352 | } | 353 | } |
353 | 354 | ||
354 | /** | 355 | /** |
355 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 356 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
356 | * load the plugin and append it to the list | 357 | * load the plugin and append it to the list |
357 | */ | 358 | */ |
358 | void MainWindowImp::addClicked() | 359 | void MainWindowImp::addClicked() |
359 | { | 360 | { |
360 | QMap<Module*, QLibrary*>::Iterator it; | 361 | QMap<Module*, QLibrary*>::Iterator it; |
361 | QMap<QString, QString> list; | 362 | QMap<QString, QString> list; |
362 | QMap<QString, Module*> newInterfaceOwners; | 363 | QMap<QString, Module*> newInterfaceOwners; |
363 | 364 | ||
364 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 365 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
365 | { | 366 | { |
366 | if(it.key()) | 367 | if(it.key()) |
367 | { | 368 | { |
368 | (it.key())->possibleNewInterfaces(list); | 369 | (it.key())->possibleNewInterfaces(list); |
369 | } | 370 | } |
370 | } | 371 | } |
371 | // See if the list has anything that we can add. | 372 | // See if the list has anything that we can add. |
372 | if(list.count() == 0) | 373 | if(list.count() == 0) |
373 | { | 374 | { |
374 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 375 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
375 | return; | 376 | return; |
376 | } | 377 | } |
377 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 378 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
378 | addNewConnection.addConnections(list); | 379 | addNewConnection.addConnections(list); |
379 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) | 380 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
380 | { | 381 | { |
381 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 382 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
382 | if(!item) | 383 | if(!item) |
383 | return; | 384 | return; |
384 | 385 | ||
385 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 386 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
386 | { | 387 | { |
387 | if(it.key()) | 388 | if(it.key()) |
388 | { | 389 | { |
389 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 390 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
390 | if(i) | 391 | if(i) |
391 | { | 392 | { |
392 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; | 393 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; |
393 | interfaceNames.insert(i->getInterfaceName(), i); | 394 | interfaceNames.insert(i->getInterfaceName(), i); |
394 | updateInterface(i); | 395 | updateInterface(i); |
395 | } | 396 | } |
396 | } | 397 | } |
397 | } | 398 | } |
398 | } | 399 | } |
399 | } | 400 | } |
400 | 401 | ||
401 | /** | 402 | /** |
402 | * Prompt the user to see if they really want to do this. | 403 | * Prompt the user to see if they really want to do this. |
403 | * If they do then remove from the list and unload. | 404 | * If they do then remove from the list and unload. |
404 | */ | 405 | */ |
405 | void MainWindowImp::removeClicked() | 406 | void MainWindowImp::removeClicked() |
406 | { | 407 | { |
407 | QListViewItem *item = connectionList->currentItem(); | 408 | QListViewItem *item = connectionList->currentItem(); |
408 | if(!item) | 409 | if(!item) |
409 | { | 410 | { |
410 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 411 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
411 | return; | 412 | return; |
412 | } | 413 | } |
413 | 414 | ||
414 | Interface *i = interfaceItems[item]; | 415 | Interface *i = interfaceItems[item]; |
415 | if(i->getModuleOwner() == NULL) | 416 | if(i->getModuleOwner() == NULL) |
416 | { | 417 | { |
417 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 418 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
418 | } | 419 | } |
419 | else | 420 | else |
420 | { | 421 | { |
421 | if(!i->getModuleOwner()->remove(i)) | 422 | if(!i->getModuleOwner()->remove(i)) |
422 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 423 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
423 | else | 424 | else |
424 | { | 425 | { |
425 | delete item; | 426 | delete item; |
426 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 427 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
427 | } | 428 | } |
428 | } | 429 | } |
429 | } | 430 | } |
430 | 431 | ||
431 | /** | 432 | /** |
432 | * Pull up the configure about the currently selected interface. | 433 | * Pull up the configure about the currently selected interface. |
433 | * Report an error if no interface is selected. | 434 | * Report an error if no interface is selected. |
434 | * If the interface has a module owner then request its configure. | 435 | * If the interface has a module owner then request its configure. |
435 | */ | 436 | */ |
436 | void MainWindowImp::configureClicked() | 437 | void MainWindowImp::configureClicked() |
437 | { | 438 | { |
438 | QListViewItem *item = connectionList->currentItem(); | 439 | QListViewItem *item = connectionList->currentItem(); |
439 | if(!item) | 440 | if(!item) |
440 | { | 441 | { |
441 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 442 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
442 | return; | 443 | return; |
443 | } | 444 | } |
444 | 445 | ||
445 | QString currentProfileText = currentProfileLabel->text(); | 446 | QString currentProfileText = currentProfileLabel->text(); |
446 | if(currentProfileText.upper() == "ALL"); | 447 | if(currentProfileText.upper() == "ALL"); |
447 | currentProfileText = ""; | 448 | currentProfileText = ""; |
448 | 449 | ||
449 | Interface *i = interfaceItems[item]; | 450 | Interface *i = interfaceItems[item]; |
450 | 451 | ||
451 | if(i->getModuleOwner()) | 452 | if(i->getModuleOwner()) |
452 | { | 453 | { |
453 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 454 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
454 | if(moduleConfigure != NULL) | 455 | if(moduleConfigure != NULL) |
455 | { | 456 | { |
456 | i->getModuleOwner()->setProfile(currentProfileText); | 457 | i->getModuleOwner()->setProfile(currentProfileText); |
457 | QPEApplication::showWidget( moduleConfigure ); | 458 | QPEApplication::showWidget( moduleConfigure ); |
458 | return; | 459 | return; |
459 | } | 460 | } |
460 | } | 461 | } |
461 | 462 | ||
462 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 463 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
463 | configure->setProfile(currentProfileText); | 464 | configure->setProfile(currentProfileText); |
464 | QPEApplication::showDialog( configure ); | 465 | QPEApplication::showDialog( configure ); |
465 | } | 466 | } |
466 | 467 | ||
467 | /** | 468 | /** |
468 | * Pull up the information about the currently selected interface. | 469 | * Pull up the information about the currently selected interface. |
469 | * Report an error if no interface is selected. | 470 | * Report an error if no interface is selected. |
470 | * If the interface has a module owner then request its configure. | 471 | * If the interface has a module owner then request its configure. |
471 | */ | 472 | */ |
472 | void MainWindowImp::informationClicked() | 473 | void MainWindowImp::informationClicked() |
473 | { | 474 | { |
474 | QListViewItem *item = connectionList->currentItem(); | 475 | QListViewItem *item = connectionList->currentItem(); |
475 | if(!item) | 476 | if(!item) |
476 | { | 477 | { |
477 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 478 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
478 | return; | 479 | return; |
479 | } | 480 | } |
480 | 481 | ||
481 | Interface *i = interfaceItems[item]; | 482 | Interface *i = interfaceItems[item]; |
482 | // if(!i->isAttached()){ | 483 | // if(!i->isAttached()){ |
483 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 484 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
484 | // return; | 485 | // return; |
485 | // } | 486 | // } |
486 | 487 | ||
487 | if(i->getModuleOwner()) | 488 | if(i->getModuleOwner()) |
488 | { | 489 | { |
489 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 490 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
490 | if(moduleInformation != NULL) | 491 | if(moduleInformation != NULL) |
491 | { | 492 | { |
492 | QPEApplication::showWidget( moduleInformation ); | 493 | QPEApplication::showWidget( moduleInformation ); |
493 | #ifdef DEBUG | 494 | #ifdef DEBUG |
494 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; | 495 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; |
495 | #endif | 496 | #endif |
496 | return; | 497 | return; |
497 | } | 498 | } |
498 | } | 499 | } |
499 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); | 500 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
500 | QPEApplication::showWidget( information ); | 501 | QPEApplication::showWidget( information ); |
501 | } | 502 | } |
502 | 503 | ||
503 | /** | 504 | /** |
504 | * Update this interface. If no QListViewItem exists create one. | 505 | * Update this interface. If no QListViewItem exists create one. |
505 | * @param Interface* pointer to the interface that needs to be updated. | 506 | * @param Interface* pointer to the interface that needs to be updated. |
506 | */ | 507 | */ |
507 | void MainWindowImp::updateInterface(Interface *i) | 508 | void MainWindowImp::updateInterface(Interface *i) |
508 | { | 509 | { |
509 | if(!advancedUserMode) | 510 | if(!advancedUserMode) |
510 | { | 511 | { |
511 | if(i->getInterfaceName() == "lo") | 512 | if(i->getInterfaceName() == "lo") |
512 | return; | 513 | return; |
513 | } | 514 | } |
514 | 515 | ||
515 | QListViewItem *item = NULL; | 516 | QListViewItem *item = NULL; |
516 | 517 | ||
517 | // Find the interface, making it if needed. | 518 | // Find the interface, making it if needed. |
518 | if(items.find(i) == items.end()) | 519 | if(items.find(i) == items.end()) |
519 | { | 520 | { |
520 | item = new QListViewItem(connectionList, "", "", ""); | 521 | item = new QListViewItem(connectionList, "", "", ""); |
521 | // See if you can't find a module owner for this interface | 522 | // See if you can't find a module owner for this interface |
522 | QMap<Module*, QLibrary*>::Iterator it; | 523 | QMap<Module*, QLibrary*>::Iterator it; |
523 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 524 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
524 | { | 525 | { |
525 | if(it.key()->isOwner(i)) | 526 | if(it.key()->isOwner(i)) |
526 | i->setModuleOwner(it.key()); | 527 | i->setModuleOwner(it.key()); |
527 | } | 528 | } |
528 | items.insert(i, item); | 529 | items.insert(i, item); |
529 | interfaceItems.insert(item, i); | 530 | interfaceItems.insert(item, i); |
530 | } | 531 | } |
531 | else | 532 | else |
532 | item = items[i]; | 533 | item = items[i]; |
533 | 534 | ||
534 | // Update the icons and information | 535 | // Update the icons and information |
535 | #ifdef QWS | 536 | item->setPixmap( 0, Opie::Core::OResource::loadPixmap( i->getStatus() ? "up" : "down", Opie::Core::OResource::SmallIcon ) ); |
536 | QPixmap pic; | ||
537 | pic.convertFromImage( Resource::loadImage( i->getStatus() ? "up": "down" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | ||
538 | item->setPixmap(0, ( pic )); | ||
539 | #else | ||
540 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | ||
541 | #endif | ||
542 | 537 | ||
543 | QString typeName = "lan"; | 538 | QString typeName = "lan"; |
544 | if(i->getInterfaceName() == "lo") | 539 | if(i->getInterfaceName() == "lo") |
545 | typeName = "lo"; | 540 | typeName = "lo"; |
546 | if(i->getInterfaceName().contains("irda")) | 541 | if(i->getInterfaceName().contains("irda")) |
547 | typeName = "irda"; | 542 | typeName = "irda"; |
548 | if(i->getInterfaceName().contains("wlan")) | 543 | if(i->getInterfaceName().contains("wlan")) |
549 | typeName = "wlan"; | 544 | typeName = "wlan"; |
550 | if(i->getInterfaceName().contains("usb")) | 545 | if(i->getInterfaceName().contains("usb")) |
551 | typeName = "usb"; | 546 | typeName = "usb"; |
552 | 547 | ||
553 | if(!i->isAttached()) | 548 | if(!i->isAttached()) |
554 | typeName = "connect_no"; | 549 | typeName = "connect_no"; |
555 | // Actually try to use the Module | 550 | // Actually try to use the Module |
556 | if(i->getModuleOwner() != NULL) | 551 | if(i->getModuleOwner() != NULL) |
557 | typeName = i->getModuleOwner()->getPixmapName(i); | 552 | typeName = i->getModuleOwner()->getPixmapName(i); |
558 | 553 | ||
559 | #ifdef QWS | 554 | item->setPixmap( 1, ( Opie::Core::OResource::loadPixmap( "networksettings/" + typeName, Opie::Core::OResource::SmallIcon ) ) ); |
560 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 555 | |
561 | #else | ||
562 | item->setPixmap(1, (SmallIcon(typeName))); | ||
563 | #endif | ||
564 | item->setText(2, i->getHardwareName()); | 556 | item->setText(2, i->getHardwareName()); |
565 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 557 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
566 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 558 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
567 | } | 559 | } |
568 | 560 | ||
569 | void MainWindowImp::newProfileChanged(const QString& newText) | 561 | void MainWindowImp::newProfileChanged(const QString& newText) |
570 | { | 562 | { |
571 | if(newText.length() > 0) | 563 | if(newText.length() > 0) |
572 | newProfileButton->setEnabled(true); | 564 | newProfileButton->setEnabled(true); |
573 | else | 565 | else |
574 | newProfileButton->setEnabled(false); | 566 | newProfileButton->setEnabled(false); |
575 | } | 567 | } |
576 | 568 | ||
577 | /** | 569 | /** |
578 | * Adds a new profile to the list of profiles. | 570 | * Adds a new profile to the list of profiles. |
579 | * Don't add profiles that already exists. | 571 | * Don't add profiles that already exists. |
580 | * Appends to the list and QStringList | 572 | * Appends to the list and QStringList |
581 | */ | 573 | */ |
582 | void MainWindowImp::addProfile() | 574 | void MainWindowImp::addProfile() |
583 | { | 575 | { |
584 | QString newProfileName = newProfile->text(); | 576 | QString newProfileName = newProfile->text(); |
585 | if(profiles.grep(newProfileName).count() > 0) | 577 | if(profiles.grep(newProfileName).count() > 0) |
586 | { | 578 | { |
587 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 579 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
588 | return; | 580 | return; |
589 | } | 581 | } |
590 | profiles.append(newProfileName); | 582 | profiles.append(newProfileName); |
591 | profilesList->insertItem(newProfileName); | 583 | profilesList->insertItem(newProfileName); |
592 | } | 584 | } |
593 | 585 | ||
594 | /** | 586 | /** |
595 | * Removes the currently selected profile in the combo. | 587 | * Removes the currently selected profile in the combo. |
596 | * Doesn't delete if there are less then 2 profiles. | 588 | * Doesn't delete if there are less then 2 profiles. |
597 | */ | 589 | */ |
598 | void MainWindowImp::removeProfile() | 590 | void MainWindowImp::removeProfile() |
599 | { | 591 | { |
600 | if(profilesList->count() <= 1) | 592 | if(profilesList->count() <= 1) |
601 | { | 593 | { |
602 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 594 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
603 | return; | 595 | return; |
604 | } | 596 | } |
605 | QString profileToRemove = profilesList->currentText(); | 597 | QString profileToRemove = profilesList->currentText(); |
606 | if(profileToRemove == "All") | 598 | if(profileToRemove == "All") |
607 | { | 599 | { |
608 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 600 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
609 | return; | 601 | return; |
610 | } | 602 | } |
611 | // Can't remove the curent profile | 603 | // Can't remove the curent profile |
612 | if(profileToRemove == currentProfileLabel->text()) | 604 | if(profileToRemove == currentProfileLabel->text()) |
613 | { | 605 | { |
614 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 606 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
615 | return; | 607 | return; |
616 | 608 | ||
617 | } | 609 | } |
618 | 610 | ||
619 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) | 611 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
620 | { | 612 | { |
621 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 613 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
622 | profilesList->clear(); | 614 | profilesList->clear(); |
623 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 615 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
624 | profilesList->insertItem((*it)); | 616 | profilesList->insertItem((*it)); |
625 | 617 | ||
626 | // Remove any interface settings and mappings. | 618 | // Remove any interface settings and mappings. |
627 | Interfaces interfaces; | 619 | Interfaces interfaces; |
628 | // Go through them one by one | 620 | // Go through them one by one |
629 | QMap<Interface*, QListViewItem*>::Iterator it; | 621 | QMap<Interface*, QListViewItem*>::Iterator it; |
630 | for( it = items.begin(); it != items.end(); ++it ) | 622 | for( it = items.begin(); it != items.end(); ++it ) |
631 | { | 623 | { |
632 | QString interfaceName = it.key()->getInterfaceName(); | 624 | QString interfaceName = it.key()->getInterfaceName(); |
633 | odebug << interfaceName.latin1() << oendl; | 625 | odebug << interfaceName.latin1() << oendl; |
634 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) | 626 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
635 | { | 627 | { |
636 | interfaces.removeInterface(); | 628 | interfaces.removeInterface(); |
637 | if(interfaces.setMapping(interfaceName)) | 629 | if(interfaces.setMapping(interfaceName)) |
638 | { | 630 | { |
639 | if(profilesList->count() == 1) | 631 | if(profilesList->count() == 1) |
640 | interfaces.removeMapping(); | 632 | interfaces.removeMapping(); |
641 | else | 633 | else |
642 | { | 634 | { |
643 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 635 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
644 | } | 636 | } |
645 | } | 637 | } |
646 | interfaces.write(); | 638 | interfaces.write(); |
647 | break; | 639 | break; |
648 | } | 640 | } |
649 | } | 641 | } |
650 | } | 642 | } |
651 | } | 643 | } |
652 | 644 | ||
653 | /** | 645 | /** |
654 | * A new profile has been selected, change. | 646 | * A new profile has been selected, change. |
655 | * @param newProfile the new profile. | 647 | * @param newProfile the new profile. |
656 | */ | 648 | */ |
657 | void MainWindowImp::changeProfile() | 649 | void MainWindowImp::changeProfile() |
658 | { | 650 | { |
659 | if(profilesList->currentItem() == -1) | 651 | if(profilesList->currentItem() == -1) |
660 | { | 652 | { |
661 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 653 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
662 | return; | 654 | return; |
663 | } | 655 | } |
664 | QString newProfile = profilesList->text(profilesList->currentItem()); | 656 | QString newProfile = profilesList->text(profilesList->currentItem()); |
665 | if(newProfile != currentProfileLabel->text()) | 657 | if(newProfile != currentProfileLabel->text()) |
666 | { | 658 | { |
667 | currentProfileLabel->setText(newProfile); | 659 | currentProfileLabel->setText(newProfile); |
668 | QFile::remove(scheme); | 660 | QFile::remove(scheme); |
669 | QFile file(scheme); | 661 | QFile file(scheme); |
670 | if ( file.open(IO_ReadWrite) ) | 662 | if ( file.open(IO_ReadWrite) ) |
671 | { | 663 | { |
672 | QTextStream stream( &file ); | 664 | QTextStream stream( &file ); |
673 | stream << QString("SCHEME=%1").arg(newProfile); | 665 | stream << QString("SCHEME=%1").arg(newProfile); |
674 | file.close(); | 666 | file.close(); |
675 | } | 667 | } |
676 | // restart all up devices? | 668 | // restart all up devices? |
677 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) | 669 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) |
678 | { | 670 | { |
679 | // Go through them one by one | 671 | // Go through them one by one |
680 | QMap<Interface*, QListViewItem*>::Iterator it; | 672 | QMap<Interface*, QListViewItem*>::Iterator it; |
681 | for( it = items.begin(); it != items.end(); ++it ) | 673 | for( it = items.begin(); it != items.end(); ++it ) |
682 | { | 674 | { |
683 | if(it.key()->getStatus() == true) | 675 | if(it.key()->getStatus() == true) |
684 | it.key()->restart(); | 676 | it.key()->restart(); |
685 | } | 677 | } |
686 | } | 678 | } |
687 | } | 679 | } |
688 | // TODO change the profile in the modules | 680 | // TODO change the profile in the modules |
689 | } | 681 | } |
690 | 682 | ||
691 | 683 | ||
692 | void MainWindowImp::makeChannel() | 684 | void MainWindowImp::makeChannel() |
693 | { | 685 | { |
694 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 686 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
695 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 687 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
696 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 688 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
697 | } | 689 | } |
698 | 690 | ||
699 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 691 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
700 | { | 692 | { |
701 | bool found = false; | 693 | bool found = false; |
702 | odebug << "MainWindowImp::receive QCop msg >"+msg+"<" << oendl; | 694 | odebug << "MainWindowImp::receive QCop msg >"+msg+"<" << oendl; |
703 | if (msg == "raise") | 695 | if (msg == "raise") |
704 | { | 696 | { |
705 | raise(); | 697 | raise(); |
706 | return; | 698 | return; |
707 | } | 699 | } |
708 | 700 | ||
709 | QString dest = msg.left(msg.find("(")); | 701 | QString dest = msg.left(msg.find("(")); |
710 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 702 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
711 | param = param.left( param.length() - 1 ); | 703 | param = param.left( param.length() - 1 ); |
712 | odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl; | 704 | odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl; |
713 | 705 | ||
714 | QMap<Module*, QLibrary*>::Iterator it; | 706 | QMap<Module*, QLibrary*>::Iterator it; |
715 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 707 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
716 | { | 708 | { |
717 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; | 709 | odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl; |
718 | if(it.key()->type() == dest) | 710 | if(it.key()->type() == dest) |
719 | { | 711 | { |
720 | it.key()->receive( param, arg ); | 712 | it.key()->receive( param, arg ); |
721 | found = true; | 713 | found = true; |
722 | } | 714 | } |
723 | } | 715 | } |
724 | 716 | ||
725 | 717 | ||
726 | if (found) QPEApplication::setKeepRunning(); | 718 | if (found) QPEApplication::setKeepRunning(); |
727 | else odebug << "Huh what do ya want" << oendl; | 719 | else odebug << "Huh what do ya want" << oendl; |
728 | } | 720 | } |
729 | 721 | ||
730 | void MainWindowImp::setHostname() | 722 | void MainWindowImp::setHostname() |
731 | { | 723 | { |
732 | static QRegExp filter("[^A-Za-z0-9_\\-\\.]"); | 724 | static QRegExp filter("[^A-Za-z0-9_\\-\\.]"); |
733 | if (filter.match(m_Nameinput->text())!=-1) { | 725 | if (filter.match(m_Nameinput->text())!=-1) { |
734 | odebug << "Wrong hostname" << oendl; | 726 | odebug << "Wrong hostname" << oendl; |
735 | QMessageBox::critical(0, tr("Sorry"), tr("This is a wrong name.<br>Please use A-Z, a-z, _, - or a single dot.")); | 727 | QMessageBox::critical(0, tr("Sorry"), tr("This is a wrong name.<br>Please use A-Z, a-z, _, - or a single dot.")); |
736 | return; | 728 | return; |
737 | } | 729 | } |
738 | 730 | ||
739 | OProcess h; | 731 | OProcess h; |
740 | _procTemp=""; | 732 | _procTemp=""; |
741 | h << "hostname" << m_Nameinput->text(); | 733 | h << "hostname" << m_Nameinput->text(); |
742 | connect(&h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); | 734 | connect(&h,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); |
743 | h.start(OProcess::Block,OProcess::Stderr); | 735 | h.start(OProcess::Block,OProcess::Stderr); |
744 | odebug << "Got " << _procTemp << " - " << h.exitStatus() << oendl; | 736 | odebug << "Got " << _procTemp << " - " << h.exitStatus() << oendl; |
745 | if (h.exitStatus()!=0) { | 737 | if (h.exitStatus()!=0) { |
746 | QMessageBox::critical(0, tr("Sorry"), QString(tr("Could not set name.\n%1")).arg(_procTemp.stripWhiteSpace())); | 738 | QMessageBox::critical(0, tr("Sorry"), QString(tr("Could not set name.\n%1")).arg(_procTemp.stripWhiteSpace())); |
747 | return; | 739 | return; |
748 | } | 740 | } |
749 | _procTemp=""; | 741 | _procTemp=""; |
750 | 742 | ||
751 | QFile f(_HOSTFILE); | 743 | QFile f(_HOSTFILE); |
752 | if (f.open(IO_Truncate|IO_WriteOnly)) | 744 | if (f.open(IO_Truncate|IO_WriteOnly)) |
753 | { | 745 | { |
754 | QTextStream s(&f); | 746 | QTextStream s(&f); |
755 | s << m_Nameinput->text(); | 747 | s << m_Nameinput->text(); |
756 | } else { | 748 | } else { |
757 | QMessageBox::critical(0, tr("Sorry"), tr("Could not save name.")); | 749 | QMessageBox::critical(0, tr("Sorry"), tr("Could not save name.")); |
758 | return; | 750 | return; |
759 | } | 751 | } |
760 | 752 | ||
761 | f.close(); | 753 | f.close(); |
762 | f.setName(_IRDANAME); | 754 | f.setName(_IRDANAME); |
763 | if (f.open(IO_WriteOnly)) | 755 | if (f.open(IO_WriteOnly)) |
764 | { | 756 | { |
765 | QTextStream s(&f); | 757 | QTextStream s(&f); |
766 | s << m_Nameinput->text(); | 758 | s << m_Nameinput->text(); |
767 | } else { | 759 | } else { |
768 | QMessageBox::critical(0, tr("Sorry"), tr("Could not set infrared name.")); | 760 | QMessageBox::critical(0, tr("Sorry"), tr("Could not set infrared name.")); |
769 | } | 761 | } |
770 | } | 762 | } |
771 | 763 | ||
772 | void MainWindowImp::initHostname() | 764 | void MainWindowImp::initHostname() |
773 | { | 765 | { |
774 | OProcess h; | 766 | OProcess h; |
775 | _procTemp=""; | 767 | _procTemp=""; |
776 | 768 | ||
777 | h << "hostname"; | 769 | h << "hostname"; |
778 | connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); | 770 | connect(&h,SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),this,SLOT(slotHostname(Opie::Core::OProcess*,char*,int))); |
779 | h.start(OProcess::Block,OProcess::AllOutput); | 771 | h.start(OProcess::Block,OProcess::AllOutput); |
780 | odebug << "Got " << _procTemp <<oendl; | 772 | odebug << "Got " << _procTemp <<oendl; |
781 | m_Nameinput->setText(_procTemp.stripWhiteSpace()); | 773 | m_Nameinput->setText(_procTemp.stripWhiteSpace()); |
782 | _procTemp=""; | 774 | _procTemp=""; |
783 | } | 775 | } |
784 | 776 | ||
785 | void MainWindowImp::slotHostname(Opie::Core::OProcess *proc, char *buffer, int buflen) | 777 | void MainWindowImp::slotHostname(Opie::Core::OProcess */*proc*/, char *buffer, int buflen) |
786 | { | 778 | { |
787 | if (buflen < 1 || buffer==0) return; | 779 | if (buflen < 1 || buffer==0) return; |
788 | char*_t = new char[buflen+1]; | 780 | char*_t = new char[buflen+1]; |
789 | ::memset(_t,0,buflen+1); | 781 | ::memset(_t,0,buflen+1); |
790 | ::memcpy(_t,buffer,buflen); | 782 | ::memcpy(_t,buffer,buflen); |
791 | _procTemp+=_t; | 783 | _procTemp+=_t; |
792 | delete[]_t; | 784 | delete[]_t; |
793 | } | 785 | } |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 6c9735c..0abf161 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -1,1211 +1,1215 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * | 7 | * |
8 | * based on EzPPP: | 8 | * based on EzPPP: |
9 | * Copyright (C) 1997 Jay Painter | 9 | * Copyright (C) 1997 Jay Painter |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "edit.h" | 26 | #include "edit.h" |
27 | #include "pppdata.h" | 27 | #include "pppdata.h" |
28 | #include "iplined.h" | 28 | #include "iplined.h" |
29 | #include "auth.h" | 29 | #include "auth.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <qpe/resource.h> | 32 | #include <opie2/oresource.h> |
33 | |||
34 | #include <qpe/applnk.h> | ||
33 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
34 | 36 | ||
35 | /* QT */ | 37 | /* QT */ |
36 | #include <qlayout.h> | 38 | #include <qlayout.h> |
37 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
38 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
39 | #include <qregexp.h> | 41 | #include <qregexp.h> |
40 | #include <qapplication.h> | 42 | #include <qapplication.h> |
41 | #include <qbuttongroup.h> | 43 | #include <qbuttongroup.h> |
42 | #include <qvgroupbox.h> | 44 | #include <qvgroupbox.h> |
43 | #include <qhbox.h> | 45 | #include <qhbox.h> |
44 | #include <qdialog.h> | 46 | #include <qdialog.h> |
45 | 47 | ||
46 | /* STD */ | 48 | /* STD */ |
47 | 49 | ||
48 | #include <string.h> | 50 | #include <string.h> |
49 | #include <termios.h> | 51 | #include <termios.h> |
50 | 52 | ||
51 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 53 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
52 | , const char *name ) | 54 | , const char *name ) |
53 | : QWidget(parent, name), _pppdata(pd) | 55 | : QWidget(parent, name), _pppdata(pd) |
54 | { | 56 | { |
55 | const int GRIDROWS = 6; | 57 | const int GRIDROWS = 6; |
56 | 58 | ||
57 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); | 59 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
58 | 60 | ||
59 | connect_label = new QLabel(tr("Connection name:"), this); | 61 | connect_label = new QLabel(tr("Connection name:"), this); |
60 | tl->addWidget(connect_label, 0, 0); | 62 | tl->addWidget(connect_label, 0, 0); |
61 | 63 | ||
62 | connectname_l = new QLineEdit(this); | 64 | connectname_l = new QLineEdit(this); |
63 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 65 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
64 | tl->addWidget(connectname_l, 0, 1); | 66 | tl->addWidget(connectname_l, 0, 1); |
65 | QString tmp = tr("Type in a unique name for this connection"); | 67 | QString tmp = tr("Type in a unique name for this connection"); |
66 | 68 | ||
67 | QWhatsThis::add(connect_label,tmp); | 69 | QWhatsThis::add(connect_label,tmp); |
68 | QWhatsThis::add(connectname_l,tmp); | 70 | QWhatsThis::add(connectname_l,tmp); |
69 | 71 | ||
70 | 72 | ||
71 | number_label = new QLabel(tr("Phone number:"), this); | 73 | number_label = new QLabel(tr("Phone number:"), this); |
72 | number_label->setAlignment(AlignTop|AlignLeft); | 74 | number_label->setAlignment(AlignTop|AlignLeft); |
73 | tl->addWidget(number_label, 1, 0); | 75 | tl->addWidget(number_label, 1, 0); |
74 | 76 | ||
75 | QHBoxLayout *lpn = new QHBoxLayout(5); | 77 | QHBoxLayout *lpn = new QHBoxLayout(5); |
76 | tl->addLayout(lpn, 1, 1); | 78 | tl->addLayout(lpn, 1, 1); |
77 | numbers = new QListBox(this); | 79 | numbers = new QListBox(this); |
78 | // numbers->setMinimumSize(120, 70); | 80 | // numbers->setMinimumSize(120, 70); |
79 | lpn->addWidget(numbers); | 81 | lpn->addWidget(numbers); |
80 | QVBoxLayout *lpn1 = new QVBoxLayout; | 82 | QVBoxLayout *lpn1 = new QVBoxLayout; |
81 | lpn->addLayout(lpn1); | 83 | lpn->addLayout(lpn1); |
82 | add = new QPushButton(tr("&Add..."), this); | 84 | add = new QPushButton(tr("&Add..."), this); |
83 | del = new QPushButton(tr("&Remove"), this); | 85 | del = new QPushButton(tr("&Remove"), this); |
84 | 86 | ||
85 | up = new QPushButton(this); | 87 | up = new QPushButton(this); |
86 | up->setPixmap( Resource::loadPixmap("up") ); | 88 | up->setPixmap( Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon) ); |
89 | up->setMinimumHeight( AppLnk::smallIconSize()+4 ); | ||
87 | down = new QPushButton(this); | 90 | down = new QPushButton(this); |
88 | down->setPixmap( Resource::loadPixmap("down") ); | 91 | down->setPixmap( Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon) ); |
92 | down->setMinimumHeight( AppLnk::smallIconSize()+4 ); | ||
89 | lpn1->addWidget(add); | 93 | lpn1->addWidget(add); |
90 | lpn1->addWidget(del); | 94 | lpn1->addWidget(del); |
91 | lpn1->addStretch(1); | 95 | lpn1->addStretch(1); |
92 | lpn1->addWidget(up); | 96 | lpn1->addWidget(up); |
93 | lpn1->addWidget(down); | 97 | lpn1->addWidget(down); |
94 | connect(add, SIGNAL(clicked()), | 98 | connect(add, SIGNAL(clicked()), |
95 | this, SLOT(addNumber())); | 99 | this, SLOT(addNumber())); |
96 | connect(del, SIGNAL(clicked()), | 100 | connect(del, SIGNAL(clicked()), |
97 | this, SLOT(delNumber())); | 101 | this, SLOT(delNumber())); |
98 | connect(up, SIGNAL(clicked()), | 102 | connect(up, SIGNAL(clicked()), |
99 | this, SLOT(upNumber())); | 103 | this, SLOT(upNumber())); |
100 | connect(down, SIGNAL(clicked()), | 104 | connect(down, SIGNAL(clicked()), |
101 | this, SLOT(downNumber())); | 105 | this, SLOT(downNumber())); |
102 | connect(numbers, SIGNAL(highlighted(int)), | 106 | connect(numbers, SIGNAL(highlighted(int)), |
103 | this, SLOT(selectionChanged(int))); | 107 | this, SLOT(selectionChanged(int))); |
104 | numbersChanged(); | 108 | numbersChanged(); |
105 | 109 | ||
106 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 110 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
107 | "can supply multiple numbers here, simply\n" | 111 | "can supply multiple numbers here, simply\n" |
108 | "click on \"Add\". You can arrange the\n" | 112 | "click on \"Add\". You can arrange the\n" |
109 | "order the numbers are tried by using the\n" | 113 | "order the numbers are tried by using the\n" |
110 | "arrow buttons.\n\n" | 114 | "arrow buttons.\n\n" |
111 | "When a number is busy or fails, <i>kppp</i> will \n" | 115 | "When a number is busy or fails, <i>kppp</i> will \n" |
112 | "try the next number and so on"); | 116 | "try the next number and so on"); |
113 | 117 | ||
114 | QWhatsThis::add(number_label,tmp); | 118 | QWhatsThis::add(number_label,tmp); |
115 | QWhatsThis::add(numbers,tmp); | 119 | QWhatsThis::add(numbers,tmp); |
116 | 120 | ||
117 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 121 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
118 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 122 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
119 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 123 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
120 | 124 | ||
121 | // Set defaults if editing an existing connection | 125 | // Set defaults if editing an existing connection |
122 | if(!isnewaccount) | 126 | if(!isnewaccount) |
123 | { | 127 | { |
124 | connectname_l->setText(_pppdata->accname()); | 128 | connectname_l->setText(_pppdata->accname()); |
125 | 129 | ||
126 | // insert the phone numbers into the listbox | 130 | // insert the phone numbers into the listbox |
127 | QString n = _pppdata->phonenumber(); | 131 | QString n = _pppdata->phonenumber(); |
128 | QString tmp = ""; | 132 | QString tmp = ""; |
129 | uint idx = 0; | 133 | uint idx = 0; |
130 | while(idx != n.length()) | 134 | while(idx != n.length()) |
131 | { | 135 | { |
132 | if(n[idx] == ':') | 136 | if(n[idx] == ':') |
133 | { | 137 | { |
134 | if(tmp.length() > 0) | 138 | if(tmp.length() > 0) |
135 | numbers->insertItem(tmp); | 139 | numbers->insertItem(tmp); |
136 | tmp = ""; | 140 | tmp = ""; |
137 | } | 141 | } |
138 | else | 142 | else |
139 | tmp += n[idx]; | 143 | tmp += n[idx]; |
140 | idx++; | 144 | idx++; |
141 | } | 145 | } |
142 | if(tmp.length() > 0) | 146 | if(tmp.length() > 0) |
143 | numbers->insertItem(tmp); | 147 | numbers->insertItem(tmp); |
144 | 148 | ||
145 | } | 149 | } |
146 | 150 | ||
147 | numbersChanged(); | 151 | numbersChanged(); |
148 | tl->activate(); | 152 | tl->activate(); |
149 | } | 153 | } |
150 | 154 | ||
151 | bool DialWidget::save() | 155 | bool DialWidget::save() |
152 | { | 156 | { |
153 | //first check to make sure that the account name is unique! | 157 | //first check to make sure that the account name is unique! |
154 | if(connectname_l->text().isEmpty() || | 158 | if(connectname_l->text().isEmpty() || |
155 | !_pppdata->isUniqueAccname(connectname_l->text())) | 159 | !_pppdata->isUniqueAccname(connectname_l->text())) |
156 | { | 160 | { |
157 | return false; | 161 | return false; |
158 | } | 162 | } |
159 | else | 163 | else |
160 | { | 164 | { |
161 | _pppdata->setAccname(connectname_l->text()); | 165 | _pppdata->setAccname(connectname_l->text()); |
162 | 166 | ||
163 | QString number = ""; | 167 | QString number = ""; |
164 | for(uint i = 0; i < numbers->count(); i++) | 168 | for(uint i = 0; i < numbers->count(); i++) |
165 | { | 169 | { |
166 | if(i != 0) | 170 | if(i != 0) |
167 | number += ":"; | 171 | number += ":"; |
168 | number += numbers->text(i); | 172 | number += numbers->text(i); |
169 | } | 173 | } |
170 | 174 | ||
171 | _pppdata->setPhonenumber(number); | 175 | _pppdata->setPhonenumber(number); |
172 | return true; | 176 | return true; |
173 | } | 177 | } |
174 | } | 178 | } |
175 | 179 | ||
176 | 180 | ||
177 | void DialWidget::numbersChanged() | 181 | void DialWidget::numbersChanged() |
178 | { | 182 | { |
179 | int sel = numbers->currentItem(); | 183 | int sel = numbers->currentItem(); |
180 | 184 | ||
181 | del->setEnabled(sel != -1); | 185 | del->setEnabled(sel != -1); |
182 | up->setEnabled(sel != -1 && sel != 0); | 186 | up->setEnabled(sel != -1 && sel != 0); |
183 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 187 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
184 | } | 188 | } |
185 | 189 | ||
186 | 190 | ||
187 | void DialWidget::selectionChanged(int) | 191 | void DialWidget::selectionChanged(int) |
188 | { | 192 | { |
189 | numbersChanged(); | 193 | numbersChanged(); |
190 | } | 194 | } |
191 | 195 | ||
192 | 196 | ||
193 | void DialWidget::addNumber() | 197 | void DialWidget::addNumber() |
194 | { | 198 | { |
195 | PhoneNumberDialog dlg(this); | 199 | PhoneNumberDialog dlg(this); |
196 | if(dlg.exec()) | 200 | if(dlg.exec()) |
197 | { | 201 | { |
198 | numbers->insertItem(dlg.phoneNumber()); | 202 | numbers->insertItem(dlg.phoneNumber()); |
199 | numbersChanged(); | 203 | numbersChanged(); |
200 | } | 204 | } |
201 | } | 205 | } |
202 | 206 | ||
203 | 207 | ||
204 | void DialWidget::delNumber() | 208 | void DialWidget::delNumber() |
205 | { | 209 | { |
206 | if(numbers->currentItem() != -1) | 210 | if(numbers->currentItem() != -1) |
207 | { | 211 | { |
208 | numbers->removeItem(numbers->currentItem()); | 212 | numbers->removeItem(numbers->currentItem()); |
209 | numbersChanged(); | 213 | numbersChanged(); |
210 | } | 214 | } |
211 | } | 215 | } |
212 | 216 | ||
213 | 217 | ||
214 | void DialWidget::upNumber() | 218 | void DialWidget::upNumber() |
215 | { | 219 | { |
216 | int idx = numbers->currentItem(); | 220 | int idx = numbers->currentItem(); |
217 | if(idx != -1) | 221 | if(idx != -1) |
218 | { | 222 | { |
219 | QString item = numbers->text(idx); | 223 | QString item = numbers->text(idx); |
220 | numbers->removeItem(idx); | 224 | numbers->removeItem(idx); |
221 | numbers->insertItem(item, idx-1); | 225 | numbers->insertItem(item, idx-1); |
222 | numbers->setCurrentItem(idx-1); | 226 | numbers->setCurrentItem(idx-1); |
223 | numbersChanged(); | 227 | numbersChanged(); |
224 | } | 228 | } |
225 | } | 229 | } |
226 | 230 | ||
227 | 231 | ||
228 | void DialWidget::downNumber() | 232 | void DialWidget::downNumber() |
229 | { | 233 | { |
230 | int idx = numbers->currentItem(); | 234 | int idx = numbers->currentItem(); |
231 | if(idx != -1) | 235 | if(idx != -1) |
232 | { | 236 | { |
233 | QString item = numbers->text(idx); | 237 | QString item = numbers->text(idx); |
234 | numbers->removeItem(idx); | 238 | numbers->removeItem(idx); |
235 | numbers->insertItem(item, idx+1); | 239 | numbers->insertItem(item, idx+1); |
236 | numbers->setCurrentItem(idx+1); | 240 | numbers->setCurrentItem(idx+1); |
237 | numbersChanged(); | 241 | numbersChanged(); |
238 | } | 242 | } |
239 | } | 243 | } |
240 | 244 | ||
241 | 245 | ||
242 | void DialWidget::pppdargsbutton() | 246 | void DialWidget::pppdargsbutton() |
243 | { | 247 | { |
244 | PPPdArguments pa(_pppdata, this); | 248 | PPPdArguments pa(_pppdata, this); |
245 | QPEApplication::execDialog( &pa ); | 249 | QPEApplication::execDialog( &pa ); |
246 | } | 250 | } |
247 | 251 | ||
248 | 252 | ||
249 | 253 | ||
250 | ///////////////////////////////////////////////////////////////////////////// | 254 | ///////////////////////////////////////////////////////////////////////////// |
251 | // ExecWidget | 255 | // ExecWidget |
252 | ///////////////////////////////////////////////////////////////////////////// | 256 | ///////////////////////////////////////////////////////////////////////////// |
253 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 257 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
254 | QWidget(parent, name), _pppdata(pd) | 258 | QWidget(parent, name), _pppdata(pd) |
255 | { | 259 | { |
256 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 260 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
257 | 261 | ||
258 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); | 262 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); |
259 | 263 | ||
260 | tl->addWidget(l); | 264 | tl->addWidget(l); |
261 | tl->addStretch(1); | 265 | tl->addStretch(1); |
262 | 266 | ||
263 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 267 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
264 | tl->addLayout(l1); | 268 | tl->addLayout(l1); |
265 | l1->setColStretch(0, 0); | 269 | l1->setColStretch(0, 0); |
266 | l1->setColStretch(1, 1); | 270 | l1->setColStretch(1, 1); |
267 | 271 | ||
268 | before_connect_l = new QLabel(tr("Before connect:"), this); | 272 | before_connect_l = new QLabel(tr("Before connect:"), this); |
269 | before_connect_l->setAlignment(AlignVCenter); | 273 | before_connect_l->setAlignment(AlignVCenter); |
270 | l1->addWidget(before_connect_l, 0, 0); | 274 | l1->addWidget(before_connect_l, 0, 0); |
271 | before_connect = new QLineEdit(this); | 275 | before_connect = new QLineEdit(this); |
272 | // before_connect->setMaxLength(COMMAND_SIZE); | 276 | // before_connect->setMaxLength(COMMAND_SIZE); |
273 | l1->addWidget(before_connect, 0, 1); | 277 | l1->addWidget(before_connect, 0, 1); |
274 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 278 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
275 | "is established. It is called immediately before\n" | 279 | "is established. It is called immediately before\n" |
276 | "dialing has begun.\n\n" | 280 | "dialing has begun.\n\n" |
277 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 281 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
278 | "modem."); | 282 | "modem."); |
279 | 283 | ||
280 | QWhatsThis::add(before_connect_l,tmp); | 284 | QWhatsThis::add(before_connect_l,tmp); |
281 | QWhatsThis::add(before_connect,tmp); | 285 | QWhatsThis::add(before_connect,tmp); |
282 | 286 | ||
283 | command_label = new QLabel(tr("Upon connect:"), this); | 287 | command_label = new QLabel(tr("Upon connect:"), this); |
284 | command_label->setAlignment(AlignVCenter); | 288 | command_label->setAlignment(AlignVCenter); |
285 | l1->addWidget(command_label, 1, 0); | 289 | l1->addWidget(command_label, 1, 0); |
286 | command = new QLineEdit(this); | 290 | command = new QLineEdit(this); |
287 | // command->setMaxLength(COMMAND_SIZE); | 291 | // command->setMaxLength(COMMAND_SIZE); |
288 | l1->addWidget(command, 1, 1); | 292 | l1->addWidget(command, 1, 1); |
289 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 293 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
290 | "is established. When your program is called, all\n" | 294 | "is established. When your program is called, all\n" |
291 | "preparations for an Internet connection are finished.\n" | 295 | "preparations for an Internet connection are finished.\n" |
292 | "\n" | 296 | "\n" |
293 | "Very useful for fetching mail and news"); | 297 | "Very useful for fetching mail and news"); |
294 | 298 | ||
295 | QWhatsThis::add(command_label,tmp); | 299 | QWhatsThis::add(command_label,tmp); |
296 | QWhatsThis::add(command,tmp); | 300 | QWhatsThis::add(command,tmp); |
297 | 301 | ||
298 | predisconnect_label = new QLabel(tr("Before disconnect:"), | 302 | predisconnect_label = new QLabel(tr("Before disconnect:"), |
299 | this); | 303 | this); |
300 | predisconnect_label->setAlignment(AlignVCenter); | 304 | predisconnect_label->setAlignment(AlignVCenter); |
301 | l1->addWidget(predisconnect_label, 2, 0); | 305 | l1->addWidget(predisconnect_label, 2, 0); |
302 | predisconnect = new QLineEdit(this); | 306 | predisconnect = new QLineEdit(this); |
303 | // predisconnect->setMaxLength(COMMAND_SIZE); | 307 | // predisconnect->setMaxLength(COMMAND_SIZE); |
304 | l1->addWidget(predisconnect, 2, 1); | 308 | l1->addWidget(predisconnect, 2, 1); |
305 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 309 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
306 | "is closed. The connection will stay open until\n" | 310 | "is closed. The connection will stay open until\n" |
307 | "the program exits."); | 311 | "the program exits."); |
308 | 312 | ||
309 | QWhatsThis::add(predisconnect_label,tmp); | 313 | QWhatsThis::add(predisconnect_label,tmp); |
310 | QWhatsThis::add(predisconnect,tmp); | 314 | QWhatsThis::add(predisconnect,tmp); |
311 | 315 | ||
312 | discommand_label = new QLabel(tr("Upon disconnect:"), | 316 | discommand_label = new QLabel(tr("Upon disconnect:"), |
313 | this); | 317 | this); |
314 | discommand_label->setAlignment(AlignVCenter); | 318 | discommand_label->setAlignment(AlignVCenter); |
315 | l1->addWidget(discommand_label, 3, 0); | 319 | l1->addWidget(discommand_label, 3, 0); |
316 | 320 | ||
317 | discommand = new QLineEdit(this); | 321 | discommand = new QLineEdit(this); |
318 | // discommand->setMaxLength(COMMAND_SIZE); | 322 | // discommand->setMaxLength(COMMAND_SIZE); |
319 | l1->addWidget(discommand, 3, 1); | 323 | l1->addWidget(discommand, 3, 1); |
320 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 324 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
321 | "has been closed."); | 325 | "has been closed."); |
322 | 326 | ||
323 | QWhatsThis::add(discommand_label,tmp); | 327 | QWhatsThis::add(discommand_label,tmp); |
324 | QWhatsThis::add(discommand,tmp); | 328 | QWhatsThis::add(discommand,tmp); |
325 | 329 | ||
326 | // extra space between entries | 330 | // extra space between entries |
327 | l1->addRowSpacing(1, 5); | 331 | l1->addRowSpacing(1, 5); |
328 | l1->addRowSpacing(3, 5); | 332 | l1->addRowSpacing(3, 5); |
329 | 333 | ||
330 | tl->addStretch(1); | 334 | tl->addStretch(1); |
331 | tl->activate(); | 335 | tl->activate(); |
332 | 336 | ||
333 | // Set defaults if editing an existing connection | 337 | // Set defaults if editing an existing connection |
334 | if(!isnewaccount) | 338 | if(!isnewaccount) |
335 | { | 339 | { |
336 | before_connect->setText(_pppdata->command_before_connect()); | 340 | before_connect->setText(_pppdata->command_before_connect()); |
337 | command->setText(_pppdata->command_on_connect()); | 341 | command->setText(_pppdata->command_on_connect()); |
338 | discommand->setText(_pppdata->command_on_disconnect()); | 342 | discommand->setText(_pppdata->command_on_disconnect()); |
339 | predisconnect->setText(_pppdata->command_before_disconnect()); | 343 | predisconnect->setText(_pppdata->command_before_disconnect()); |
340 | } | 344 | } |
341 | } | 345 | } |
342 | 346 | ||
343 | 347 | ||
344 | bool ExecWidget::save() | 348 | bool ExecWidget::save() |
345 | { | 349 | { |
346 | _pppdata->setCommand_before_connect(before_connect->text()); | 350 | _pppdata->setCommand_before_connect(before_connect->text()); |
347 | _pppdata->setCommand_on_connect(command->text()); | 351 | _pppdata->setCommand_on_connect(command->text()); |
348 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 352 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
349 | _pppdata->setCommand_on_disconnect(discommand->text()); | 353 | _pppdata->setCommand_on_disconnect(discommand->text()); |
350 | return true; | 354 | return true; |
351 | } | 355 | } |
352 | 356 | ||
353 | 357 | ||
354 | 358 | ||
355 | ///////////////////////////////////////////////////////////////////////////// | 359 | ///////////////////////////////////////////////////////////////////////////// |
356 | // | 360 | // |
357 | // IPWidget | 361 | // IPWidget |
358 | // | 362 | // |
359 | ///////////////////////////////////////////////////////////////////////////// | 363 | ///////////////////////////////////////////////////////////////////////////// |
360 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 364 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
361 | : QWidget(parent, name), _pppdata(pd) | 365 | : QWidget(parent, name), _pppdata(pd) |
362 | { | 366 | { |
363 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 367 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
364 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 368 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
365 | 369 | ||
366 | box = new QVGroupBox(tr("Configuration"), this); | 370 | box = new QVGroupBox(tr("Configuration"), this); |
367 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 371 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
368 | 372 | ||
369 | rb = new QButtonGroup(this); | 373 | rb = new QButtonGroup(this); |
370 | rb->hide(); | 374 | rb->hide(); |
371 | connect(rb, SIGNAL(clicked(int)), | 375 | connect(rb, SIGNAL(clicked(int)), |
372 | SLOT(hitIPSelect(int))); | 376 | SLOT(hitIPSelect(int))); |
373 | 377 | ||
374 | dynamicadd_rb = new QRadioButton(box); | 378 | dynamicadd_rb = new QRadioButton(box); |
375 | dynamicadd_rb->setText(tr("Dynamic IP address")); | 379 | dynamicadd_rb->setText(tr("Dynamic IP address")); |
376 | QWhatsThis::add(dynamicadd_rb, | 380 | QWhatsThis::add(dynamicadd_rb, |
377 | tr("Select this option when your computer gets an\n" | 381 | tr("Select this option when your computer gets an\n" |
378 | "internet address (IP) every time a\n" | 382 | "internet address (IP) every time a\n" |
379 | "connection is made.\n" | 383 | "connection is made.\n" |
380 | "\n" | 384 | "\n" |
381 | "Almost every Internet Service Provider uses\n" | 385 | "Almost every Internet Service Provider uses\n" |
382 | "this method, so this should be turned on.")); | 386 | "this method, so this should be turned on.")); |
383 | 387 | ||
384 | staticadd_rb = new QRadioButton(box); | 388 | staticadd_rb = new QRadioButton(box); |
385 | staticadd_rb->setText(tr("Static IP address")); | 389 | staticadd_rb->setText(tr("Static IP address")); |
386 | rb->insert(dynamicadd_rb, 0); | 390 | rb->insert(dynamicadd_rb, 0); |
387 | rb->insert(staticadd_rb, 1); | 391 | rb->insert(staticadd_rb, 1); |
388 | QWhatsThis::add(staticadd_rb, | 392 | QWhatsThis::add(staticadd_rb, |
389 | tr("Select this option when your computer has a\n" | 393 | tr("Select this option when your computer has a\n" |
390 | "fixed internet address (IP). Most computers\n" | 394 | "fixed internet address (IP). Most computers\n" |
391 | "don't have this, so you should probably select\n" | 395 | "don't have this, so you should probably select\n" |
392 | "dynamic IP addressing unless you know what you\n" | 396 | "dynamic IP addressing unless you know what you\n" |
393 | "are doing.")); | 397 | "are doing.")); |
394 | 398 | ||
395 | QWidget *ipWidget = new QWidget(box); | 399 | QWidget *ipWidget = new QWidget(box); |
396 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 400 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
397 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 401 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
398 | 402 | ||
399 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); | 403 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); |
400 | QString tmp = tr("If your computer has a permanent internet\n" | 404 | QString tmp = tr("If your computer has a permanent internet\n" |
401 | "address, you must supply your IP address here."); | 405 | "address, you must supply your IP address here."); |
402 | ipLayout->addWidget(ipaddress_label, 0, 0); | 406 | ipLayout->addWidget(ipaddress_label, 0, 0); |
403 | 407 | ||
404 | ipaddress_l = new IPLineEdit(ipWidget); | 408 | ipaddress_l = new IPLineEdit(ipWidget); |
405 | ipLayout->addWidget(ipaddress_l, 0, 1); | 409 | ipLayout->addWidget(ipaddress_l, 0, 1); |
406 | 410 | ||
407 | QWhatsThis::add(ipaddress_label,tmp); | 411 | QWhatsThis::add(ipaddress_label,tmp); |
408 | QWhatsThis::add(ipaddress_l,tmp); | 412 | QWhatsThis::add(ipaddress_l,tmp); |
409 | 413 | ||
410 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); | 414 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); |
411 | tmp = tr("<p>If your computer has a static Internet address,\n" | 415 | tmp = tr("<p>If your computer has a static Internet address,\n" |
412 | "you must supply a network mask here. In almost\n" | 416 | "you must supply a network mask here. In almost\n" |
413 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 417 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
414 | "but your mileage may vary.\n" | 418 | "but your mileage may vary.\n" |
415 | "\n" | 419 | "\n" |
416 | "If unsure, contact your Internet Service Provider"); | 420 | "If unsure, contact your Internet Service Provider"); |
417 | ipLayout->addWidget(sub_label, 1, 0); | 421 | ipLayout->addWidget(sub_label, 1, 0); |
418 | 422 | ||
419 | subnetmask_l = new IPLineEdit(ipWidget); | 423 | subnetmask_l = new IPLineEdit(ipWidget); |
420 | ipLayout->addWidget(subnetmask_l, 1, 1); | 424 | ipLayout->addWidget(subnetmask_l, 1, 1); |
421 | 425 | ||
422 | QWhatsThis::add(sub_label,tmp); | 426 | QWhatsThis::add(sub_label,tmp); |
423 | QWhatsThis::add(subnetmask_l,tmp); | 427 | QWhatsThis::add(subnetmask_l,tmp); |
424 | 428 | ||
425 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); | 429 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); |
426 | autoname->setChecked(_pppdata->autoname()); | 430 | autoname->setChecked(_pppdata->autoname()); |
427 | connect(autoname,SIGNAL(toggled(bool)), | 431 | connect(autoname,SIGNAL(toggled(bool)), |
428 | this,SLOT(autoname_t(bool))); | 432 | this,SLOT(autoname_t(bool))); |
429 | 433 | ||
430 | QWhatsThis::add(autoname, | 434 | QWhatsThis::add(autoname, |
431 | tr("<p>Whenever you connect, this reconfigures\n" | 435 | tr("<p>Whenever you connect, this reconfigures\n" |
432 | "your hostname to match the IP address you\n" | 436 | "your hostname to match the IP address you\n" |
433 | "got from the PPP server. This may be useful\n" | 437 | "got from the PPP server. This may be useful\n" |
434 | "if you need to use a protocol which depends\n" | 438 | "if you need to use a protocol which depends\n" |
435 | "on this information, but it can also cause several\n" | 439 | "on this information, but it can also cause several\n" |
436 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 440 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
437 | "\n" | 441 | "\n" |
438 | "Don't enable this unless you really need it.")); | 442 | "Don't enable this unless you really need it.")); |
439 | 443 | ||
440 | topLayout->addWidget(box); | 444 | topLayout->addWidget(box); |
441 | topLayout->addWidget(autoname); | 445 | topLayout->addWidget(autoname); |
442 | topLayout->addStretch(); | 446 | topLayout->addStretch(); |
443 | 447 | ||
444 | //load info from gpppdata | 448 | //load info from gpppdata |
445 | if(!isnewaccount) | 449 | if(!isnewaccount) |
446 | { | 450 | { |
447 | if(_pppdata->ipaddr() == "0.0.0.0" && | 451 | if(_pppdata->ipaddr() == "0.0.0.0" && |
448 | _pppdata->subnetmask() == "0.0.0.0") | 452 | _pppdata->subnetmask() == "0.0.0.0") |
449 | { | 453 | { |
450 | dynamicadd_rb->setChecked(true); | 454 | dynamicadd_rb->setChecked(true); |
451 | hitIPSelect(0); | 455 | hitIPSelect(0); |
452 | autoname->setChecked(_pppdata->autoname()); | 456 | autoname->setChecked(_pppdata->autoname()); |
453 | } | 457 | } |
454 | else | 458 | else |
455 | { | 459 | { |
456 | ipaddress_l->setText(_pppdata->ipaddr()); | 460 | ipaddress_l->setText(_pppdata->ipaddr()); |
457 | subnetmask_l->setText(_pppdata->subnetmask()); | 461 | subnetmask_l->setText(_pppdata->subnetmask()); |
458 | staticadd_rb->setChecked(true); | 462 | staticadd_rb->setChecked(true); |
459 | autoname->setChecked(false); | 463 | autoname->setChecked(false); |
460 | } | 464 | } |
461 | } | 465 | } |
462 | else | 466 | else |
463 | { | 467 | { |
464 | dynamicadd_rb->setChecked(true); | 468 | dynamicadd_rb->setChecked(true); |
465 | hitIPSelect(0); | 469 | hitIPSelect(0); |
466 | } | 470 | } |
467 | 471 | ||
468 | } | 472 | } |
469 | 473 | ||
470 | void IPWidget::autoname_t(bool on) | 474 | void IPWidget::autoname_t(bool on) |
471 | { | 475 | { |
472 | static bool was_warned = false; | 476 | static bool was_warned = false; |
473 | 477 | ||
474 | // big-fat warning when selecting the auto configure hostname option | 478 | // big-fat warning when selecting the auto configure hostname option |
475 | if(on && !was_warned) | 479 | if(on && !was_warned) |
476 | { | 480 | { |
477 | QMessageBox::information(this, | 481 | QMessageBox::information(this, |
478 | tr("Selecting this option might cause some weird " | 482 | tr("Selecting this option might cause some weird " |
479 | "problems with the X-server and applications " | 483 | "problems with the X-server and applications " |
480 | "while kppp is connected. Don't use it until " | 484 | "while kppp is connected. Don't use it until " |
481 | "you know what you are doing!\n" | 485 | "you know what you are doing!\n" |
482 | "For more information take a look at the " | 486 | "For more information take a look at the " |
483 | "handbook (or help) in the section \"Frequently " | 487 | "handbook (or help) in the section \"Frequently " |
484 | "asked questions\"."), | 488 | "asked questions\"."), |
485 | tr("Warning")); | 489 | tr("Warning")); |
486 | was_warned = true; | 490 | was_warned = true; |
487 | } | 491 | } |
488 | } | 492 | } |
489 | 493 | ||
490 | 494 | ||
491 | void IPWidget::save() | 495 | void IPWidget::save() |
492 | { | 496 | { |
493 | if(dynamicadd_rb->isChecked()) | 497 | if(dynamicadd_rb->isChecked()) |
494 | { | 498 | { |
495 | _pppdata->setIpaddr("0.0.0.0"); | 499 | _pppdata->setIpaddr("0.0.0.0"); |
496 | _pppdata->setSubnetmask("0.0.0.0"); | 500 | _pppdata->setSubnetmask("0.0.0.0"); |
497 | } | 501 | } |
498 | else | 502 | else |
499 | { | 503 | { |
500 | _pppdata->setIpaddr(ipaddress_l->text()); | 504 | _pppdata->setIpaddr(ipaddress_l->text()); |
501 | _pppdata->setSubnetmask(subnetmask_l->text()); | 505 | _pppdata->setSubnetmask(subnetmask_l->text()); |
502 | } | 506 | } |
503 | _pppdata->setAutoname(autoname->isChecked()); | 507 | _pppdata->setAutoname(autoname->isChecked()); |
504 | } | 508 | } |
505 | 509 | ||
506 | 510 | ||
507 | void IPWidget::hitIPSelect( int i ) | 511 | void IPWidget::hitIPSelect( int i ) |
508 | { | 512 | { |
509 | if(i == 0) | 513 | if(i == 0) |
510 | { | 514 | { |
511 | ipaddress_label->setEnabled(false); | 515 | ipaddress_label->setEnabled(false); |
512 | sub_label->setEnabled(false); | 516 | sub_label->setEnabled(false); |
513 | ipaddress_l->setEnabled(false); | 517 | ipaddress_l->setEnabled(false); |
514 | subnetmask_l->setEnabled(false); | 518 | subnetmask_l->setEnabled(false); |
515 | } | 519 | } |
516 | else | 520 | else |
517 | { | 521 | { |
518 | ipaddress_label->setEnabled(true); | 522 | ipaddress_label->setEnabled(true); |
519 | sub_label->setEnabled(true); | 523 | sub_label->setEnabled(true); |
520 | ipaddress_l->setEnabled(true); | 524 | ipaddress_l->setEnabled(true); |
521 | subnetmask_l->setEnabled(true); | 525 | subnetmask_l->setEnabled(true); |
522 | } | 526 | } |
523 | } | 527 | } |
524 | 528 | ||
525 | 529 | ||
526 | 530 | ||
527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 531 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
528 | : QWidget(parent, name), _pppdata(pd) | 532 | : QWidget(parent, name), _pppdata(pd) |
529 | { | 533 | { |
530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 534 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
531 | 535 | ||
532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 536 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
533 | tl->addWidget(dnsdomain_label, 0, 0); | 537 | tl->addWidget(dnsdomain_label, 0, 0); |
534 | 538 | ||
535 | dnsdomain = new QLineEdit(this); | 539 | dnsdomain = new QLineEdit(this); |
536 | 540 | ||
537 | tl->addWidget(dnsdomain, 0, 1); | 541 | tl->addWidget(dnsdomain, 0, 1); |
538 | QString tmp = tr("If you enter a domain name here, this domain\n" | 542 | QString tmp = tr("If you enter a domain name here, this domain\n" |
539 | "name is used for your computer while you are\n" | 543 | "name is used for your computer while you are\n" |
540 | "connected. When the connection is closed, the\n" | 544 | "connected. When the connection is closed, the\n" |
541 | "original domain name of your computer is\n" | 545 | "original domain name of your computer is\n" |
542 | "restored.\n" | 546 | "restored.\n" |
543 | "\n" | 547 | "\n" |
544 | "If you leave this field blank, no changes are\n" | 548 | "If you leave this field blank, no changes are\n" |
545 | "made to the domain name."); | 549 | "made to the domain name."); |
546 | 550 | ||
547 | QWhatsThis::add(dnsdomain_label,tmp); | 551 | QWhatsThis::add(dnsdomain_label,tmp); |
548 | QWhatsThis::add(dnsdomain,tmp); | 552 | QWhatsThis::add(dnsdomain,tmp); |
549 | 553 | ||
550 | conf_label = new QLabel(tr("Configuration:"), this); | 554 | conf_label = new QLabel(tr("Configuration:"), this); |
551 | tl->addWidget(conf_label, 1, 0); | 555 | tl->addWidget(conf_label, 1, 0); |
552 | 556 | ||
553 | bg = new QButtonGroup("Group", this); | 557 | bg = new QButtonGroup("Group", this); |
554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 558 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
555 | bg->hide(); | 559 | bg->hide(); |
556 | 560 | ||
557 | autodns = new QRadioButton(tr("Automatic"), this); | 561 | autodns = new QRadioButton(tr("Automatic"), this); |
558 | bg->insert(autodns, 0); | 562 | bg->insert(autodns, 0); |
559 | tl->addWidget(autodns, 1, 1); | 563 | tl->addWidget(autodns, 1, 1); |
560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 564 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
561 | autodns->setEnabled(false); | 565 | autodns->setEnabled(false); |
562 | 566 | ||
563 | mandns = new QRadioButton(tr("Manual"), this); | 567 | mandns = new QRadioButton(tr("Manual"), this); |
564 | bg->insert(mandns, 1); | 568 | bg->insert(mandns, 1); |
565 | tl->addWidget(mandns, 2, 1); | 569 | tl->addWidget(mandns, 2, 1); |
566 | 570 | ||
567 | dns_label = new QLabel(tr("DNS IP address:"), this); | 571 | dns_label = new QLabel(tr("DNS IP address:"), this); |
568 | tl->addWidget(dns_label, 3, 0); | 572 | tl->addWidget(dns_label, 3, 0); |
569 | 573 | ||
570 | QHBoxLayout *l2 = new QHBoxLayout; | 574 | QHBoxLayout *l2 = new QHBoxLayout; |
571 | tl->addLayout(l2, 3, 1); | 575 | tl->addLayout(l2, 3, 1); |
572 | dnsipaddr = new IPLineEdit(this); | 576 | dnsipaddr = new IPLineEdit(this); |
573 | connect(dnsipaddr, SIGNAL(returnPressed()), | 577 | connect(dnsipaddr, SIGNAL(returnPressed()), |
574 | SLOT(adddns())); | 578 | SLOT(adddns())); |
575 | connect(dnsipaddr, SIGNAL(textChanged(const QString&)), | 579 | connect(dnsipaddr, SIGNAL(textChanged(const QString&)), |
576 | SLOT(DNS_Edit_Changed(const QString&))); | 580 | SLOT(DNS_Edit_Changed(const QString&))); |
577 | l2->addWidget(dnsipaddr, 1); | 581 | l2->addWidget(dnsipaddr, 1); |
578 | l2->addStretch(1); | 582 | l2->addStretch(1); |
579 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" | 583 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" |
580 | "used while you are connected. When the\n" | 584 | "used while you are connected. When the\n" |
581 | "connection is closed, this DNS entry will be\n" | 585 | "connection is closed, this DNS entry will be\n" |
582 | "removed again.\n" | 586 | "removed again.\n" |
583 | "\n" | 587 | "\n" |
584 | "To add a DNS server, type in the IP address of\n" | 588 | "To add a DNS server, type in the IP address of\n" |
585 | "the DNS server here and click on <b>Add</b>"); | 589 | "the DNS server here and click on <b>Add</b>"); |
586 | 590 | ||
587 | QWhatsThis::add(dns_label, tmp); | 591 | QWhatsThis::add(dns_label, tmp); |
588 | QWhatsThis::add(dnsipaddr, tmp); | 592 | QWhatsThis::add(dnsipaddr, tmp); |
589 | 593 | ||
590 | QHBoxLayout *l1 = new QHBoxLayout; | 594 | QHBoxLayout *l1 = new QHBoxLayout; |
591 | tl->addLayout(l1, 4, 1); | 595 | tl->addLayout(l1, 4, 1); |
592 | add = new QPushButton(tr("Add"), this); | 596 | add = new QPushButton(tr("Add"), this); |
593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 597 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
594 | l1->addWidget(add); | 598 | l1->addWidget(add); |
595 | // l1->addStretch(1); | 599 | // l1->addStretch(1); |
596 | QWhatsThis::add(add, | 600 | QWhatsThis::add(add, |
597 | tr("Click this button to add the DNS server\n" | 601 | tr("Click this button to add the DNS server\n" |
598 | "specified in the field above. The entry\n" | 602 | "specified in the field above. The entry\n" |
599 | "will then be added to the list below")); | 603 | "will then be added to the list below")); |
600 | 604 | ||
601 | remove = new QPushButton(tr("Remove"), this); | 605 | remove = new QPushButton(tr("Remove"), this); |
602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 606 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
603 | l1->addWidget(remove); | 607 | l1->addWidget(remove); |
604 | QWhatsThis::add(remove, | 608 | QWhatsThis::add(remove, |
605 | tr("Click this button to remove the selected DNS\n" | 609 | tr("Click this button to remove the selected DNS\n" |
606 | "server entry from the list below")); | 610 | "server entry from the list below")); |
607 | 611 | ||
608 | servers_label = new QLabel(tr("DNS address list:"), this); | 612 | servers_label = new QLabel(tr("DNS address list:"), this); |
609 | servers_label->setAlignment(AlignTop|AlignLeft); | 613 | servers_label->setAlignment(AlignTop|AlignLeft); |
610 | tl->addWidget(servers_label, 5, 0); | 614 | tl->addWidget(servers_label, 5, 0); |
611 | 615 | ||
612 | dnsservers = new QListBox(this); | 616 | dnsservers = new QListBox(this); |
613 | dnsservers->setMinimumSize(150, 80); | 617 | dnsservers->setMinimumSize(150, 80); |
614 | connect(dnsservers, SIGNAL(highlighted(int)), | 618 | connect(dnsservers, SIGNAL(highlighted(int)), |
615 | SLOT(DNS_Entry_Selected(int))); | 619 | SLOT(DNS_Entry_Selected(int))); |
616 | tl->addWidget(dnsservers, 5, 1); | 620 | tl->addWidget(dnsservers, 5, 1); |
617 | tmp = tr("<p>This shows all defined DNS servers to use\n" | 621 | tmp = tr("<p>This shows all defined DNS servers to use\n" |
618 | "while you are connected. Use the <b>Add</b> and\n" | 622 | "while you are connected. Use the <b>Add</b> and\n" |
619 | "<b>Remove</b> buttons to modify the list"); | 623 | "<b>Remove</b> buttons to modify the list"); |
620 | 624 | ||
621 | QWhatsThis::add(servers_label,tmp); | 625 | QWhatsThis::add(servers_label,tmp); |
622 | QWhatsThis::add(dnsservers,tmp); | 626 | QWhatsThis::add(dnsservers,tmp); |
623 | 627 | ||
624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 628 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
625 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); | 629 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); |
626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 630 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 631 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
628 | QWhatsThis::add(exdnsdisabled_toggle, | 632 | QWhatsThis::add(exdnsdisabled_toggle, |
629 | tr("<p>When this option is selected, all DNS\n" | 633 | tr("<p>When this option is selected, all DNS\n" |
630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 634 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
631 | "temporary disabled while the dialup connection\n" | 635 | "temporary disabled while the dialup connection\n" |
632 | "is established. After the connection is\n" | 636 | "is established. After the connection is\n" |
633 | "closed, the servers will be re-enabled\n" | 637 | "closed, the servers will be re-enabled\n" |
634 | "\n" | 638 | "\n" |
635 | "Typically, there is no reason to use this\n" | 639 | "Typically, there is no reason to use this\n" |
636 | "option, but it may become useful under \n" | 640 | "option, but it may become useful under \n" |
637 | "some circumstances.")); | 641 | "some circumstances.")); |
638 | 642 | ||
639 | 643 | ||
640 | // restore data if editing | 644 | // restore data if editing |
641 | if(!isnewaccount) | 645 | if(!isnewaccount) |
642 | { | 646 | { |
643 | dnsservers->insertStringList(_pppdata->dns()); | 647 | dnsservers->insertStringList(_pppdata->dns()); |
644 | dnsdomain->setText(_pppdata->domain()); | 648 | dnsdomain->setText(_pppdata->domain()); |
645 | } | 649 | } |
646 | 650 | ||
647 | int mode = _pppdata->autoDNS() ? 0 : 1; | 651 | int mode = _pppdata->autoDNS() ? 0 : 1; |
648 | bg->setButton(mode); | 652 | bg->setButton(mode); |
649 | DNS_Mode_Selected(mode); | 653 | DNS_Mode_Selected(mode); |
650 | 654 | ||
651 | tl->activate(); | 655 | tl->activate(); |
652 | } | 656 | } |
653 | 657 | ||
654 | void DNSWidget::DNS_Edit_Changed(const QString &text) | 658 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
655 | { | 659 | { |
656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 660 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
657 | add->setEnabled(text.find(r) != -1); | 661 | add->setEnabled(text.find(r) != -1); |
658 | } | 662 | } |
659 | 663 | ||
660 | void DNSWidget::DNS_Entry_Selected(int) | 664 | void DNSWidget::DNS_Entry_Selected(int) |
661 | { | 665 | { |
662 | remove->setEnabled(true); | 666 | remove->setEnabled(true); |
663 | } | 667 | } |
664 | 668 | ||
665 | void DNSWidget::DNS_Mode_Selected(int mode) | 669 | void DNSWidget::DNS_Mode_Selected(int mode) |
666 | { | 670 | { |
667 | bool on = (mode == 1); | 671 | bool on = (mode == 1); |
668 | dns_label->setEnabled(on); | 672 | dns_label->setEnabled(on); |
669 | servers_label->setEnabled(on); | 673 | servers_label->setEnabled(on); |
670 | dnsipaddr->setText(""); | 674 | dnsipaddr->setText(""); |
671 | dnsipaddr->setEnabled(on); | 675 | dnsipaddr->setEnabled(on); |
672 | add->setEnabled(false); | 676 | add->setEnabled(false); |
673 | remove->setEnabled(dnsservers->count()>0 && on); | 677 | remove->setEnabled(dnsservers->count()>0 && on); |
674 | dnsservers->clearSelection(); | 678 | dnsservers->clearSelection(); |
675 | dnsservers->setEnabled(on); | 679 | dnsservers->setEnabled(on); |
676 | dnsservers->triggerUpdate(false); | 680 | dnsservers->triggerUpdate(false); |
677 | } | 681 | } |
678 | 682 | ||
679 | void DNSWidget::save() | 683 | void DNSWidget::save() |
680 | { | 684 | { |
681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 685 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
682 | QStringList serverlist; | 686 | QStringList serverlist; |
683 | for(uint i=0; i < dnsservers->count(); i++) | 687 | for(uint i=0; i < dnsservers->count(); i++) |
684 | serverlist.append(dnsservers->text(i)); | 688 | serverlist.append(dnsservers->text(i)); |
685 | _pppdata->setDns(serverlist); | 689 | _pppdata->setDns(serverlist); |
686 | 690 | ||
687 | // strip leading dot | 691 | // strip leading dot |
688 | QString s(dnsdomain->text()); | 692 | QString s(dnsdomain->text()); |
689 | if(s.left(1) == ".") | 693 | if(s.left(1) == ".") |
690 | _pppdata->setDomain(s.mid(1)); | 694 | _pppdata->setDomain(s.mid(1)); |
691 | else | 695 | else |
692 | _pppdata->setDomain(dnsdomain->text()); | 696 | _pppdata->setDomain(dnsdomain->text()); |
693 | 697 | ||
694 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 698 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
695 | } | 699 | } |
696 | 700 | ||
697 | 701 | ||
698 | void DNSWidget::adddns() | 702 | void DNSWidget::adddns() |
699 | { | 703 | { |
700 | if(dnsservers->count() < MAX_DNS_ENTRIES) | 704 | if(dnsservers->count() < MAX_DNS_ENTRIES) |
701 | { | 705 | { |
702 | dnsservers->insertItem(dnsipaddr->text()); | 706 | dnsservers->insertItem(dnsipaddr->text()); |
703 | dnsipaddr->setText(""); | 707 | dnsipaddr->setText(""); |
704 | } | 708 | } |
705 | } | 709 | } |
706 | 710 | ||
707 | 711 | ||
708 | void DNSWidget::removedns() | 712 | void DNSWidget::removedns() |
709 | { | 713 | { |
710 | int i; | 714 | int i; |
711 | i = dnsservers->currentItem(); | 715 | i = dnsservers->currentItem(); |
712 | if(i != -1) | 716 | if(i != -1) |
713 | dnsservers->removeItem(i); | 717 | dnsservers->removeItem(i); |
714 | remove->setEnabled(dnsservers->count()>0); | 718 | remove->setEnabled(dnsservers->count()>0); |
715 | } | 719 | } |
716 | 720 | ||
717 | 721 | ||
718 | // | 722 | // |
719 | // GatewayWidget | 723 | // GatewayWidget |
720 | // | 724 | // |
721 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 725 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
722 | : QWidget(parent, name), _pppdata(pd) | 726 | : QWidget(parent, name), _pppdata(pd) |
723 | { | 727 | { |
724 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 728 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
725 | topLayout->setSpacing( 2 ); | 729 | topLayout->setSpacing( 2 ); |
726 | topLayout->setMargin( 0 ); | 730 | topLayout->setMargin( 0 ); |
727 | 731 | ||
728 | box = new QVGroupBox(tr("Configuration"), this); | 732 | box = new QVGroupBox(tr("Configuration"), this); |
729 | 733 | ||
730 | rb = new QButtonGroup(this); | 734 | rb = new QButtonGroup(this); |
731 | rb->hide(); | 735 | rb->hide(); |
732 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 736 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
733 | 737 | ||
734 | defaultgateway = new QRadioButton(box); | 738 | defaultgateway = new QRadioButton(box); |
735 | defaultgateway->setText(tr("Default gateway")); | 739 | defaultgateway->setText(tr("Default gateway")); |
736 | rb->insert(defaultgateway, 0); | 740 | rb->insert(defaultgateway, 0); |
737 | QWhatsThis::add(defaultgateway, | 741 | QWhatsThis::add(defaultgateway, |
738 | tr("This makes the PPP peer computer (the computer\n" | 742 | tr("This makes the PPP peer computer (the computer\n" |
739 | "you are connected to with your modem) to act as\n" | 743 | "you are connected to with your modem) to act as\n" |
740 | "a gateway. Your computer will send all packets not\n" | 744 | "a gateway. Your computer will send all packets not\n" |
741 | "going to a computer inside your local net to this\n" | 745 | "going to a computer inside your local net to this\n" |
742 | "computer, which will route these packets.\n" | 746 | "computer, which will route these packets.\n" |
743 | "\n" | 747 | "\n" |
744 | "This is the default for most ISPs, so you should\n" | 748 | "This is the default for most ISPs, so you should\n" |
745 | "probably leave this option on.")); | 749 | "probably leave this option on.")); |
746 | 750 | ||
747 | 751 | ||
748 | staticgateway = new QRadioButton(box); | 752 | staticgateway = new QRadioButton(box); |
749 | staticgateway->setText(tr("Static gateway")); | 753 | staticgateway->setText(tr("Static gateway")); |
750 | rb->insert(staticgateway, 1); | 754 | rb->insert(staticgateway, 1); |
751 | QWhatsThis::add(staticgateway, | 755 | QWhatsThis::add(staticgateway, |
752 | tr("<p>Allows you to specify which computer you want\n" | 756 | tr("<p>Allows you to specify which computer you want\n" |
753 | "to use as gateway (see <i>Default Gateway</i> above)")); | 757 | "to use as gateway (see <i>Default Gateway</i> above)")); |
754 | 758 | ||
755 | QHBox *gateBox = new QHBox(box); | 759 | QHBox *gateBox = new QHBox(box); |
756 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); | 760 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); |
757 | gatewayaddr = new IPLineEdit(gateBox); | 761 | gatewayaddr = new IPLineEdit(gateBox); |
758 | 762 | ||
759 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), | 763 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), |
760 | this); | 764 | this); |
761 | QWhatsThis::add(defaultroute, | 765 | QWhatsThis::add(defaultroute, |
762 | tr("If this option is enabled, all packets not\n" | 766 | tr("If this option is enabled, all packets not\n" |
763 | "going to the local net are routed through\n" | 767 | "going to the local net are routed through\n" |
764 | "the PPP connection.\n" | 768 | "the PPP connection.\n" |
765 | "\n" | 769 | "\n" |
766 | "Normally, you should turn this on")); | 770 | "Normally, you should turn this on")); |
767 | 771 | ||
768 | topLayout->addWidget(box); | 772 | topLayout->addWidget(box); |
769 | topLayout->addWidget(defaultroute); | 773 | topLayout->addWidget(defaultroute); |
770 | topLayout->addStretch(); | 774 | topLayout->addStretch(); |
771 | 775 | ||
772 | //load info from gpppdata | 776 | //load info from gpppdata |
773 | if(!isnewaccount) | 777 | if(!isnewaccount) |
774 | { | 778 | { |
775 | if(_pppdata->gateway() == "0.0.0.0") | 779 | if(_pppdata->gateway() == "0.0.0.0") |
776 | { | 780 | { |
777 | defaultgateway->setChecked(true); | 781 | defaultgateway->setChecked(true); |
778 | hitGatewaySelect(0); | 782 | hitGatewaySelect(0); |
779 | } | 783 | } |
780 | else | 784 | else |
781 | { | 785 | { |
782 | gatewayaddr->setText(_pppdata->gateway()); | 786 | gatewayaddr->setText(_pppdata->gateway()); |
783 | staticgateway->setChecked(true); | 787 | staticgateway->setChecked(true); |
784 | } | 788 | } |
785 | defaultroute->setChecked(_pppdata->defaultroute()); | 789 | defaultroute->setChecked(_pppdata->defaultroute()); |
786 | } | 790 | } |
787 | else | 791 | else |
788 | { | 792 | { |
789 | defaultgateway->setChecked(true); | 793 | defaultgateway->setChecked(true); |
790 | hitGatewaySelect(0); | 794 | hitGatewaySelect(0); |
791 | defaultroute->setChecked(true); | 795 | defaultroute->setChecked(true); |
792 | } | 796 | } |
793 | } | 797 | } |
794 | 798 | ||
795 | void GatewayWidget::save() | 799 | void GatewayWidget::save() |
796 | { | 800 | { |
797 | _pppdata->setGateway(gatewayaddr->text()); | 801 | _pppdata->setGateway(gatewayaddr->text()); |
798 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 802 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
799 | } | 803 | } |
800 | 804 | ||
801 | 805 | ||
802 | void GatewayWidget::hitGatewaySelect( int i ) | 806 | void GatewayWidget::hitGatewaySelect( int i ) |
803 | { | 807 | { |
804 | if(i == 0) | 808 | if(i == 0) |
805 | { | 809 | { |
806 | gatewayaddr->setText("0.0.0.0"); | 810 | gatewayaddr->setText("0.0.0.0"); |
807 | gatewayaddr->setEnabled(false); | 811 | gatewayaddr->setEnabled(false); |
808 | gate_label->setEnabled(false); | 812 | gate_label->setEnabled(false); |
809 | } | 813 | } |
810 | else | 814 | else |
811 | { | 815 | { |
812 | gatewayaddr->setEnabled(true); | 816 | gatewayaddr->setEnabled(true); |
813 | gatewayaddr->setText(""); | 817 | gatewayaddr->setText(""); |
814 | gate_label->setEnabled(true); | 818 | gate_label->setEnabled(true); |
815 | } | 819 | } |
816 | } | 820 | } |
817 | 821 | ||
818 | 822 | ||
819 | 823 | ||
820 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 824 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
821 | : QWidget(parent, name),_pppdata(pd) | 825 | : QWidget(parent, name),_pppdata(pd) |
822 | { | 826 | { |
823 | 827 | ||
824 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 828 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
825 | se = new ScriptEdit(this); | 829 | se = new ScriptEdit(this); |
826 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 830 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
827 | tl->addWidget(se); | 831 | tl->addWidget(se); |
828 | 832 | ||
829 | // insert equal-sized buttons | 833 | // insert equal-sized buttons |
830 | QHBoxLayout *hl = new QHBoxLayout( this ); | 834 | QHBoxLayout *hl = new QHBoxLayout( this ); |
831 | tl->addLayout( hl ); | 835 | tl->addLayout( hl ); |
832 | add = new QPushButton( tr("Add"), this ); | 836 | add = new QPushButton( tr("Add"), this ); |
833 | hl->addWidget( add ); | 837 | hl->addWidget( add ); |
834 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 838 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
835 | insert = new QPushButton( tr("Insert"), this ); | 839 | insert = new QPushButton( tr("Insert"), this ); |
836 | hl->addWidget( insert ); | 840 | hl->addWidget( insert ); |
837 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 841 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
838 | remove = new QPushButton( tr("Remove"), this ); | 842 | remove = new QPushButton( tr("Remove"), this ); |
839 | hl->addWidget( remove ); | 843 | hl->addWidget( remove ); |
840 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 844 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
841 | 845 | ||
842 | QHBoxLayout *l12 = new QHBoxLayout(0); | 846 | QHBoxLayout *l12 = new QHBoxLayout(0); |
843 | tl->addLayout(l12); | 847 | tl->addLayout(l12); |
844 | stl = new QListBox(this); | 848 | stl = new QListBox(this); |
845 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 849 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
846 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 850 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
847 | // stl->setMinimumSize(QSize(70, 140)); | 851 | // stl->setMinimumSize(QSize(70, 140)); |
848 | 852 | ||
849 | sl = new QListBox(this); | 853 | sl = new QListBox(this); |
850 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 854 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
851 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 855 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
852 | // sl->setMinimumSize(QSize(150, 140)); | 856 | // sl->setMinimumSize(QSize(150, 140)); |
853 | 857 | ||
854 | slb = new QScrollBar(this); | 858 | slb = new QScrollBar(this); |
855 | // slb->setFixedWidth(slb->sizeHint().width()); | 859 | // slb->setFixedWidth(slb->sizeHint().width()); |
856 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 860 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
857 | 861 | ||
858 | l12->addWidget(stl, 1); | 862 | l12->addWidget(stl, 1); |
859 | l12->addWidget(sl, 3); | 863 | l12->addWidget(sl, 3); |
860 | l12->addWidget(slb, 0); | 864 | l12->addWidget(slb, 0); |
861 | 865 | ||
862 | //load data from gpppdata | 866 | //load data from gpppdata |
863 | if(!isnewaccount) | 867 | if(!isnewaccount) |
864 | { | 868 | { |
865 | QStringList &comlist = _pppdata->scriptType(); | 869 | QStringList &comlist = _pppdata->scriptType(); |
866 | QStringList &arglist = _pppdata->script(); | 870 | QStringList &arglist = _pppdata->script(); |
867 | QStringList::Iterator itcom = comlist.begin(); | 871 | QStringList::Iterator itcom = comlist.begin(); |
868 | QStringList::Iterator itarg = arglist.begin(); | 872 | QStringList::Iterator itarg = arglist.begin(); |
869 | 873 | ||
870 | for ( ; | 874 | for ( ; |
871 | itcom != comlist.end() && itarg != arglist.end(); | 875 | itcom != comlist.end() && itarg != arglist.end(); |
872 | ++itcom, ++itarg ) | 876 | ++itcom, ++itarg ) |
873 | { | 877 | { |
874 | stl->insertItem(*itcom); | 878 | stl->insertItem(*itcom); |
875 | sl->insertItem(*itarg); | 879 | sl->insertItem(*itarg); |
876 | } | 880 | } |
877 | } | 881 | } |
878 | 882 | ||
879 | insert->setEnabled(false); | 883 | insert->setEnabled(false); |
880 | remove->setEnabled(false); | 884 | remove->setEnabled(false); |
881 | adjustScrollBar(); | 885 | adjustScrollBar(); |
882 | tl->activate(); | 886 | tl->activate(); |
883 | } | 887 | } |
884 | 888 | ||
885 | bool ScriptWidget::check() | 889 | bool ScriptWidget::check() |
886 | { | 890 | { |
887 | uint lstart = 0; | 891 | uint lstart = 0; |
888 | uint lend = 0; | 892 | uint lend = 0; |
889 | uint errcnt = 0; | 893 | uint errcnt = 0; |
890 | 894 | ||
891 | if(sl->count() > 0) | 895 | if(sl->count() > 0) |
892 | { | 896 | { |
893 | for( uint i=0; i <= sl->count()-1; i++) | 897 | for( uint i=0; i <= sl->count()-1; i++) |
894 | { | 898 | { |
895 | if(stl->text(i) == "LoopStart") | 899 | if(stl->text(i) == "LoopStart") |
896 | { | 900 | { |
897 | lstart++; | 901 | lstart++; |
898 | } | 902 | } |
899 | if (stl->text(i) == "LoopEnd") | 903 | if (stl->text(i) == "LoopEnd") |
900 | { | 904 | { |
901 | lend++; | 905 | lend++; |
902 | } | 906 | } |
903 | if ( lend > lstart ) errcnt++; | 907 | if ( lend > lstart ) errcnt++; |
904 | } | 908 | } |
905 | return ( (errcnt == 0 ) && (lstart == lend) ); | 909 | return ( (errcnt == 0 ) && (lstart == lend) ); |
906 | } | 910 | } |
907 | return true; | 911 | return true; |
908 | } | 912 | } |
909 | 913 | ||
910 | 914 | ||
911 | void ScriptWidget::save() | 915 | void ScriptWidget::save() |
912 | { | 916 | { |
913 | QStringList typelist, arglist; | 917 | QStringList typelist, arglist; |
914 | for(uint i=0; i < sl->count(); i++) | 918 | for(uint i=0; i < sl->count(); i++) |
915 | { | 919 | { |
916 | typelist.append(stl->text(i)); | 920 | typelist.append(stl->text(i)); |
917 | arglist.append(sl->text(i)); | 921 | arglist.append(sl->text(i)); |
918 | } | 922 | } |
919 | _pppdata->setScriptType(typelist); | 923 | _pppdata->setScriptType(typelist); |
920 | _pppdata->setScript(arglist); | 924 | _pppdata->setScript(arglist); |
921 | } | 925 | } |
922 | 926 | ||
923 | 927 | ||
924 | 928 | ||
925 | void ScriptWidget::adjustScrollBar() | 929 | void ScriptWidget::adjustScrollBar() |
926 | { | 930 | { |
927 | if((int)sl->count() <= sl->numItemsVisible()) | 931 | if((int)sl->count() <= sl->numItemsVisible()) |
928 | slb->setRange(0, 0); | 932 | slb->setRange(0, 0); |
929 | else | 933 | else |
930 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 934 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
931 | } | 935 | } |
932 | 936 | ||
933 | 937 | ||
934 | void ScriptWidget::scrolling(int i) | 938 | void ScriptWidget::scrolling(int i) |
935 | { | 939 | { |
936 | sl->setTopItem(i); | 940 | sl->setTopItem(i); |
937 | stl->setTopItem(i); | 941 | stl->setTopItem(i); |
938 | } | 942 | } |
939 | 943 | ||
940 | 944 | ||
941 | void ScriptWidget::slhighlighted(int i) | 945 | void ScriptWidget::slhighlighted(int i) |
942 | { | 946 | { |
943 | insert->setEnabled(true); | 947 | insert->setEnabled(true); |
944 | remove->setEnabled(true); | 948 | remove->setEnabled(true); |
945 | stl->setCurrentItem(i); | 949 | stl->setCurrentItem(i); |
946 | } | 950 | } |
947 | 951 | ||
948 | 952 | ||
949 | void ScriptWidget::stlhighlighted(int i) | 953 | void ScriptWidget::stlhighlighted(int i) |
950 | { | 954 | { |
951 | insert->setEnabled(true); | 955 | insert->setEnabled(true); |
952 | remove->setEnabled(true); | 956 | remove->setEnabled(true); |
953 | sl->setCurrentItem(i); | 957 | sl->setCurrentItem(i); |
954 | } | 958 | } |
955 | 959 | ||
956 | 960 | ||
957 | void ScriptWidget::addButton() | 961 | void ScriptWidget::addButton() |
958 | { | 962 | { |
959 | //don't allow more than the maximum script entries | 963 | //don't allow more than the maximum script entries |
960 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 964 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
961 | return; | 965 | return; |
962 | 966 | ||
963 | switch(se->type()) | 967 | switch(se->type()) |
964 | { | 968 | { |
965 | case ScriptEdit::Expect: | 969 | case ScriptEdit::Expect: |
966 | stl->insertItem("Expect"); | 970 | stl->insertItem("Expect"); |
967 | sl->insertItem(se->text()); | 971 | sl->insertItem(se->text()); |
968 | break; | 972 | break; |
969 | 973 | ||
970 | case ScriptEdit::Send: | 974 | case ScriptEdit::Send: |
971 | stl->insertItem("Send"); | 975 | stl->insertItem("Send"); |
972 | sl->insertItem(se->text()); | 976 | sl->insertItem(se->text()); |
973 | break; | 977 | break; |
974 | 978 | ||
975 | case ScriptEdit::SendNoEcho: | 979 | case ScriptEdit::SendNoEcho: |
976 | stl->insertItem("SendNoEcho"); | 980 | stl->insertItem("SendNoEcho"); |
977 | sl->insertItem(se->text()); | 981 | sl->insertItem(se->text()); |
978 | break; | 982 | break; |
979 | 983 | ||
980 | case ScriptEdit::Pause: | 984 | case ScriptEdit::Pause: |
981 | stl->insertItem("Pause"); | 985 | stl->insertItem("Pause"); |
982 | sl->insertItem(se->text()); | 986 | sl->insertItem(se->text()); |
983 | break; | 987 | break; |
984 | 988 | ||
985 | case ScriptEdit::Hangup: | 989 | case ScriptEdit::Hangup: |
986 | stl->insertItem("Hangup"); | 990 | stl->insertItem("Hangup"); |
987 | sl->insertItem(""); | 991 | sl->insertItem(""); |
988 | break; | 992 | break; |
989 | 993 | ||
990 | case ScriptEdit::Answer: | 994 | case ScriptEdit::Answer: |
991 | stl->insertItem("Answer"); | 995 | stl->insertItem("Answer"); |
992 | sl->insertItem(""); | 996 | sl->insertItem(""); |
993 | break; | 997 | break; |
994 | 998 | ||
995 | case ScriptEdit::Timeout: | 999 | case ScriptEdit::Timeout: |
996 | stl->insertItem("Timeout"); | 1000 | stl->insertItem("Timeout"); |
997 | sl->insertItem(se->text()); | 1001 | sl->insertItem(se->text()); |
998 | break; | 1002 | break; |
999 | 1003 | ||
1000 | case ScriptEdit::Password: | 1004 | case ScriptEdit::Password: |
1001 | stl->insertItem("Password"); | 1005 | stl->insertItem("Password"); |
1002 | sl->insertItem(se->text()); | 1006 | sl->insertItem(se->text()); |
1003 | break; | 1007 | break; |
1004 | 1008 | ||
1005 | case ScriptEdit::ID: | 1009 | case ScriptEdit::ID: |
1006 | stl->insertItem("ID"); | 1010 | stl->insertItem("ID"); |
1007 | sl->insertItem(se->text()); | 1011 | sl->insertItem(se->text()); |
1008 | break; | 1012 | break; |
1009 | 1013 | ||
1010 | case ScriptEdit::Prompt: | 1014 | case ScriptEdit::Prompt: |
1011 | stl->insertItem("Prompt"); | 1015 | stl->insertItem("Prompt"); |
1012 | sl->insertItem(se->text()); | 1016 | sl->insertItem(se->text()); |
1013 | break; | 1017 | break; |
1014 | 1018 | ||
1015 | case ScriptEdit::PWPrompt: | 1019 | case ScriptEdit::PWPrompt: |
1016 | stl->insertItem("PWPrompt"); | 1020 | stl->insertItem("PWPrompt"); |
1017 | sl->insertItem(se->text()); | 1021 | sl->insertItem(se->text()); |
1018 | break; | 1022 | break; |
1019 | 1023 | ||
1020 | case ScriptEdit::LoopStart: | 1024 | case ScriptEdit::LoopStart: |
1021 | stl->insertItem("LoopStart"); | 1025 | stl->insertItem("LoopStart"); |
1022 | sl->insertItem(se->text()); | 1026 | sl->insertItem(se->text()); |
1023 | break; | 1027 | break; |
1024 | 1028 | ||
1025 | case ScriptEdit::LoopEnd: | 1029 | case ScriptEdit::LoopEnd: |
1026 | stl->insertItem("LoopEnd"); | 1030 | stl->insertItem("LoopEnd"); |
1027 | sl->insertItem(se->text()); | 1031 | sl->insertItem(se->text()); |
1028 | break; | 1032 | break; |
1029 | 1033 | ||
1030 | case ScriptEdit::Scan: | 1034 | case ScriptEdit::Scan: |
1031 | stl->insertItem("Scan"); | 1035 | stl->insertItem("Scan"); |
1032 | sl->insertItem(se->text()); | 1036 | sl->insertItem(se->text()); |
1033 | break; | 1037 | break; |
1034 | 1038 | ||
1035 | case ScriptEdit::Save: | 1039 | case ScriptEdit::Save: |
1036 | stl->insertItem("Save"); | 1040 | stl->insertItem("Save"); |
1037 | sl->insertItem(se->text()); | 1041 | sl->insertItem(se->text()); |
1038 | break; | 1042 | break; |
1039 | 1043 | ||
1040 | default: | 1044 | default: |
1041 | break; | 1045 | break; |
1042 | } | 1046 | } |
1043 | 1047 | ||
1044 | //get the scrollbar adjusted, and scroll the list so we can see what | 1048 | //get the scrollbar adjusted, and scroll the list so we can see what |
1045 | //we're adding to | 1049 | //we're adding to |
1046 | adjustScrollBar(); | 1050 | adjustScrollBar(); |
1047 | slb->setValue(slb->maxValue()); | 1051 | slb->setValue(slb->maxValue()); |
1048 | 1052 | ||
1049 | //clear the text in the entry box | 1053 | //clear the text in the entry box |
1050 | se->setText(""); | 1054 | se->setText(""); |
1051 | } | 1055 | } |
1052 | 1056 | ||
1053 | 1057 | ||
1054 | void ScriptWidget::insertButton() | 1058 | void ScriptWidget::insertButton() |
1055 | { | 1059 | { |
1056 | //exit if there is no highlighted item, or we've reached the | 1060 | //exit if there is no highlighted item, or we've reached the |
1057 | //maximum entries in the script list | 1061 | //maximum entries in the script list |
1058 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1062 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1059 | return; | 1063 | return; |
1060 | 1064 | ||
1061 | switch(se->type()) | 1065 | switch(se->type()) |
1062 | { | 1066 | { |
1063 | case ScriptEdit::Expect: | 1067 | case ScriptEdit::Expect: |
1064 | stl->insertItem("Expect", stl->currentItem()); | 1068 | stl->insertItem("Expect", stl->currentItem()); |
1065 | sl->insertItem(se->text(), sl->currentItem()); | 1069 | sl->insertItem(se->text(), sl->currentItem()); |
1066 | break; | 1070 | break; |
1067 | 1071 | ||
1068 | case ScriptEdit::Send: | 1072 | case ScriptEdit::Send: |
1069 | stl->insertItem("Send", stl->currentItem()); | 1073 | stl->insertItem("Send", stl->currentItem()); |
1070 | sl->insertItem(se->text(), sl->currentItem()); | 1074 | sl->insertItem(se->text(), sl->currentItem()); |
1071 | break; | 1075 | break; |
1072 | 1076 | ||
1073 | case ScriptEdit::SendNoEcho: | 1077 | case ScriptEdit::SendNoEcho: |
1074 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1078 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1075 | sl->insertItem(se->text(), sl->currentItem()); | 1079 | sl->insertItem(se->text(), sl->currentItem()); |
1076 | break; | 1080 | break; |
1077 | 1081 | ||
1078 | case ScriptEdit::Pause: | 1082 | case ScriptEdit::Pause: |
1079 | stl->insertItem("Pause", stl->currentItem()); | 1083 | stl->insertItem("Pause", stl->currentItem()); |
1080 | sl->insertItem(se->text(), sl->currentItem()); | 1084 | sl->insertItem(se->text(), sl->currentItem()); |
1081 | break; | 1085 | break; |
1082 | 1086 | ||
1083 | case ScriptEdit::Hangup: | 1087 | case ScriptEdit::Hangup: |
1084 | stl->insertItem("Hangup", stl->currentItem()); | 1088 | stl->insertItem("Hangup", stl->currentItem()); |
1085 | sl->insertItem("", sl->currentItem()); | 1089 | sl->insertItem("", sl->currentItem()); |
1086 | break; | 1090 | break; |
1087 | 1091 | ||
1088 | case ScriptEdit::Answer: | 1092 | case ScriptEdit::Answer: |
1089 | stl->insertItem("Answer", stl->currentItem()); | 1093 | stl->insertItem("Answer", stl->currentItem()); |
1090 | sl->insertItem("", sl->currentItem()); | 1094 | sl->insertItem("", sl->currentItem()); |
1091 | break; | 1095 | break; |
1092 | 1096 | ||
1093 | case ScriptEdit::Timeout: | 1097 | case ScriptEdit::Timeout: |
1094 | stl->insertItem("Timeout", stl->currentItem()); | 1098 | stl->insertItem("Timeout", stl->currentItem()); |
1095 | sl->insertItem(se->text(), sl->currentItem()); | 1099 | sl->insertItem(se->text(), sl->currentItem()); |
1096 | break; | 1100 | break; |
1097 | 1101 | ||
1098 | case ScriptEdit::Password: | 1102 | case ScriptEdit::Password: |
1099 | stl->insertItem("Password", stl->currentItem()); | 1103 | stl->insertItem("Password", stl->currentItem()); |
1100 | sl->insertItem(se->text(), sl->currentItem()); | 1104 | sl->insertItem(se->text(), sl->currentItem()); |
1101 | break; | 1105 | break; |
1102 | 1106 | ||
1103 | case ScriptEdit::ID: | 1107 | case ScriptEdit::ID: |
1104 | stl->insertItem("ID", stl->currentItem()); | 1108 | stl->insertItem("ID", stl->currentItem()); |
1105 | sl->insertItem(se->text(), sl->currentItem()); | 1109 | sl->insertItem(se->text(), sl->currentItem()); |
1106 | break; | 1110 | break; |
1107 | 1111 | ||
1108 | case ScriptEdit::Prompt: | 1112 | case ScriptEdit::Prompt: |
1109 | stl->insertItem("Prompt", stl->currentItem()); | 1113 | stl->insertItem("Prompt", stl->currentItem()); |
1110 | sl->insertItem(se->text(), sl->currentItem()); | 1114 | sl->insertItem(se->text(), sl->currentItem()); |
1111 | break; | 1115 | break; |
1112 | 1116 | ||
1113 | case ScriptEdit::PWPrompt: | 1117 | case ScriptEdit::PWPrompt: |
1114 | stl->insertItem("PWPrompt", stl->currentItem()); | 1118 | stl->insertItem("PWPrompt", stl->currentItem()); |
1115 | sl->insertItem(se->text(), sl->currentItem()); | 1119 | sl->insertItem(se->text(), sl->currentItem()); |
1116 | break; | 1120 | break; |
1117 | 1121 | ||
1118 | case ScriptEdit::LoopStart: | 1122 | case ScriptEdit::LoopStart: |
1119 | stl->insertItem("LoopStart", stl->currentItem()); | 1123 | stl->insertItem("LoopStart", stl->currentItem()); |
1120 | sl->insertItem(se->text(), sl->currentItem()); | 1124 | sl->insertItem(se->text(), sl->currentItem()); |
1121 | break; | 1125 | break; |
1122 | 1126 | ||
1123 | case ScriptEdit::LoopEnd: | 1127 | case ScriptEdit::LoopEnd: |
1124 | stl->insertItem("LoopEnd", stl->currentItem()); | 1128 | stl->insertItem("LoopEnd", stl->currentItem()); |
1125 | sl->insertItem(se->text(), sl->currentItem()); | 1129 | sl->insertItem(se->text(), sl->currentItem()); |
1126 | break; | 1130 | break; |
1127 | 1131 | ||
1128 | case ScriptEdit::Scan: | 1132 | case ScriptEdit::Scan: |
1129 | stl->insertItem("Scan", stl->currentItem()); | 1133 | stl->insertItem("Scan", stl->currentItem()); |
1130 | sl->insertItem(se->text(), sl->currentItem()); | 1134 | sl->insertItem(se->text(), sl->currentItem()); |
1131 | break; | 1135 | break; |
1132 | 1136 | ||
1133 | case ScriptEdit::Save: | 1137 | case ScriptEdit::Save: |
1134 | stl->insertItem("Save", stl->currentItem()); | 1138 | stl->insertItem("Save", stl->currentItem()); |
1135 | sl->insertItem(se->text(), sl->currentItem()); | 1139 | sl->insertItem(se->text(), sl->currentItem()); |
1136 | break; | 1140 | break; |
1137 | 1141 | ||
1138 | default: | 1142 | default: |
1139 | break; | 1143 | break; |
1140 | } | 1144 | } |
1141 | adjustScrollBar(); | 1145 | adjustScrollBar(); |
1142 | se->setText(""); | 1146 | se->setText(""); |
1143 | } | 1147 | } |
1144 | 1148 | ||
1145 | 1149 | ||
1146 | void ScriptWidget::removeButton() | 1150 | void ScriptWidget::removeButton() |
1147 | { | 1151 | { |
1148 | if(sl->currentItem() >= 0) | 1152 | if(sl->currentItem() >= 0) |
1149 | { | 1153 | { |
1150 | int stlc = stl->currentItem(); | 1154 | int stlc = stl->currentItem(); |
1151 | sl->removeItem(sl->currentItem()); | 1155 | sl->removeItem(sl->currentItem()); |
1152 | stl->removeItem(stlc); | 1156 | stl->removeItem(stlc); |
1153 | adjustScrollBar(); | 1157 | adjustScrollBar(); |
1154 | insert->setEnabled(sl->currentItem() != -1); | 1158 | insert->setEnabled(sl->currentItem() != -1); |
1155 | remove->setEnabled(sl->currentItem() != -1); | 1159 | remove->setEnabled(sl->currentItem() != -1); |
1156 | } | 1160 | } |
1157 | } | 1161 | } |
1158 | 1162 | ||
1159 | 1163 | ||
1160 | 1164 | ||
1161 | ///////////////////////////////////////////////////////////////////////////// | 1165 | ///////////////////////////////////////////////////////////////////////////// |
1162 | // | 1166 | // |
1163 | // Used to specify a new phone number | 1167 | // Used to specify a new phone number |
1164 | // | 1168 | // |
1165 | ///////////////////////////////////////////////////////////////////////////// | 1169 | ///////////////////////////////////////////////////////////////////////////// |
1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1170 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1167 | : QDialog(parent,"PhoneNumberDialog",true) | 1171 | : QDialog(parent,"PhoneNumberDialog",true) |
1168 | { | 1172 | { |
1169 | setCaption( tr("Add Phone Number") ); | 1173 | setCaption( tr("Add Phone Number") ); |
1170 | 1174 | ||
1171 | 1175 | ||
1172 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1176 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1173 | layout->setSpacing( 3 ); | 1177 | layout->setSpacing( 3 ); |
1174 | layout->setMargin( 3 ); | 1178 | layout->setMargin( 3 ); |
1175 | 1179 | ||
1176 | // QHBox *hbox = new QHBox(this); | 1180 | // QHBox *hbox = new QHBox(this); |
1177 | // setMainWidget(hbox); | 1181 | // setMainWidget(hbox); |
1178 | 1182 | ||
1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1183 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1180 | 1184 | ||
1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1185 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1182 | layout->addWidget( label ); | 1186 | layout->addWidget( label ); |
1183 | 1187 | ||
1184 | le = new QLineEdit(this, "lineEdit"); | 1188 | le = new QLineEdit(this, "lineEdit"); |
1185 | layout->addWidget( le ); | 1189 | layout->addWidget( le ); |
1186 | 1190 | ||
1187 | connect(le, SIGNAL(textChanged(const QString&)), | 1191 | connect(le, SIGNAL(textChanged(const QString&)), |
1188 | this, SLOT(textChanged(const QString&))); | 1192 | this, SLOT(textChanged(const QString&))); |
1189 | 1193 | ||
1190 | le->setFocus(); | 1194 | le->setFocus(); |
1191 | textChanged(""); | 1195 | textChanged(""); |
1192 | 1196 | ||
1193 | 1197 | ||
1194 | } | 1198 | } |
1195 | 1199 | ||
1196 | 1200 | ||
1197 | QString PhoneNumberDialog::phoneNumber() | 1201 | QString PhoneNumberDialog::phoneNumber() |
1198 | { | 1202 | { |
1199 | QString s = le->text(); | 1203 | QString s = le->text(); |
1200 | 1204 | ||
1201 | return s; | 1205 | return s; |
1202 | } | 1206 | } |
1203 | 1207 | ||
1204 | 1208 | ||
1205 | void PhoneNumberDialog::textChanged(const QString &) | 1209 | void PhoneNumberDialog::textChanged(const QString &) |
1206 | { | 1210 | { |
1207 | // enableButtonOK(s.length() > 0); | 1211 | // enableButtonOK(s.length() > 0); |
1208 | } | 1212 | } |
1209 | 1213 | ||
1210 | 1214 | ||
1211 | //#include "edit.moc" | 1215 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 2fd97c3..0c18bcc 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,627 +1,627 @@ | |||
1 | #include "wlanimp2.h" | 1 | #include "wlanimp2.h" |
2 | #include "keyedit.h" | 2 | #include "keyedit.h" |
3 | #include "interfacesetupimp.h" | 3 | #include "interfacesetupimp.h" |
4 | #include "../interfaces/interface.h" | 4 | #include "../interfaces/interface.h" |
5 | 5 | ||
6 | #include <assert.h> | 6 | #include <assert.h> |
7 | #include <errno.h> | 7 | #include <errno.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | #include <opie2/odebug.h> | 11 | #include <opie2/odebug.h> |
12 | #include <opie2/oprocess.h> | 12 | #include <opie2/oprocess.h> |
13 | #include <opie2/onetwork.h> | 13 | #include <opie2/onetwork.h> |
14 | #include <opie2/opcap.h> | 14 | #include <opie2/opcap.h> |
15 | #include <qpe/resource.h> | 15 | #include <opie2/oresource.h> |
16 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
17 | using namespace Opie::Net; | 17 | using namespace Opie::Net; |
18 | 18 | ||
19 | /* QT */ | 19 | /* QT */ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
29 | #include <qradiobutton.h> | 29 | #include <qradiobutton.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qprogressbar.h> | 36 | #include <qprogressbar.h> |
37 | 37 | ||
38 | /* STD */ | 38 | /* STD */ |
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | 42 | ||
43 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 43 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
44 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" | 44 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Constructor, read in the wireless.opts file for parsing later. | 47 | * Constructor, read in the wireless.opts file for parsing later. |
48 | */ | 48 | */ |
49 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 49 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
50 | interfaces = new Interfaces(); | 50 | interfaces = new Interfaces(); |
51 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 51 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
52 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 52 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
53 | 53 | ||
54 | // Check sanity - the existance of the wireless-tools if-pre-up script | 54 | // Check sanity - the existance of the wireless-tools if-pre-up script |
55 | QFile file(QString(PREUP)); | 55 | QFile file(QString(PREUP)); |
56 | if (file.exists()) { | 56 | if (file.exists()) { |
57 | owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; | 57 | owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; |
58 | } | 58 | } |
59 | 59 | ||
60 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 60 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
61 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); | 61 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); |
62 | netView->setColumnAlignment( col_chn, AlignCenter ); | 62 | netView->setColumnAlignment( col_chn, AlignCenter ); |
63 | netView->setItemMargin( 3 ); | 63 | netView->setItemMargin( 3 ); |
64 | netView->setAllColumnsShowFocus( true ); | 64 | netView->setAllColumnsShowFocus( true ); |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | WLANImp::~WLANImp() { | 68 | WLANImp::~WLANImp() { |
69 | //FIXME: delete interfaces; | 69 | //FIXME: delete interfaces; |
70 | } | 70 | } |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Change the profile for both wireless settings and network settings. | 73 | * Change the profile for both wireless settings and network settings. |
74 | */ | 74 | */ |
75 | void WLANImp::setProfile(const QString &profile){ | 75 | void WLANImp::setProfile(const QString &profile){ |
76 | interfaceSetup->setProfile(profile); | 76 | interfaceSetup->setProfile(profile); |
77 | parseOpts(); | 77 | parseOpts(); |
78 | } | 78 | } |
79 | 79 | ||
80 | void WLANImp::parseOpts() { | 80 | void WLANImp::parseOpts() { |
81 | bool error; | 81 | bool error; |
82 | QString opt,key; | 82 | QString opt,key; |
83 | 83 | ||
84 | if (! interfaces->isInterfaceSet()) | 84 | if (! interfaces->isInterfaceSet()) |
85 | return; | 85 | return; |
86 | 86 | ||
87 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 87 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
88 | if(opt == "any" || opt == "off" || opt.isNull()){ | 88 | if(opt == "any" || opt == "off" || opt.isNull()){ |
89 | essid->setEditText("any"); | 89 | essid->setEditText("any"); |
90 | } else { | 90 | } else { |
91 | essid->setEditText(opt); | 91 | essid->setEditText(opt); |
92 | } | 92 | } |
93 | 93 | ||
94 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 94 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
95 | 95 | ||
96 | for ( int i = 0; i < mode->count(); i++) | 96 | for ( int i = 0; i < mode->count(); i++) |
97 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); | 97 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
98 | 98 | ||
99 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 99 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
100 | if (! opt.isNull()) { | 100 | if (! opt.isNull()) { |
101 | specifyAp->setChecked(true); | 101 | specifyAp->setChecked(true); |
102 | macEdit->setText(opt); | 102 | macEdit->setText(opt); |
103 | } | 103 | } |
104 | 104 | ||
105 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 105 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
106 | if (! opt.isNull()) { | 106 | if (! opt.isNull()) { |
107 | specifyChan->setChecked(true); | 107 | specifyChan->setChecked(true); |
108 | networkChannel->setValue(opt.toInt()); | 108 | networkChannel->setValue(opt.toInt()); |
109 | } | 109 | } |
110 | 110 | ||
111 | opt = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); | 111 | opt = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); |
112 | 112 | ||
113 | if ( opt == "wlan-ng") { | 113 | if ( opt == "wlan-ng") { |
114 | 114 | ||
115 | //FIXME:Handle wlan_ng_priv_genstr | 115 | //FIXME:Handle wlan_ng_priv_genstr |
116 | 116 | ||
117 | // get default key_id | 117 | // get default key_id |
118 | opt = interfaces->getInterfaceOption("wlan_ng_default_key_id", error).simplifyWhiteSpace(); | 118 | opt = interfaces->getInterfaceOption("wlan_ng_default_key_id", error).simplifyWhiteSpace(); |
119 | 119 | ||
120 | if (opt == "0") | 120 | if (opt == "0") |
121 | keyRadio0->setChecked(true); | 121 | keyRadio0->setChecked(true); |
122 | if (opt == "1") | 122 | if (opt == "1") |
123 | keyRadio1->setChecked(true); | 123 | keyRadio1->setChecked(true); |
124 | if (opt == "2") | 124 | if (opt == "2") |
125 | keyRadio2->setChecked(true); | 125 | keyRadio2->setChecked(true); |
126 | if (opt == "3") | 126 | if (opt == "3") |
127 | keyRadio3->setChecked(true); | 127 | keyRadio3->setChecked(true); |
128 | 128 | ||
129 | // get key0 | 129 | // get key0 |
130 | key = interfaces->getInterfaceOption("wlan_ng_key0", error).simplifyWhiteSpace(); | 130 | key = interfaces->getInterfaceOption("wlan_ng_key0", error).simplifyWhiteSpace(); |
131 | key.replace(QString(":"),QString("")); | 131 | key.replace(QString(":"),QString("")); |
132 | keyLineEdit0->setText(key); | 132 | keyLineEdit0->setText(key); |
133 | 133 | ||
134 | // get key1 | 134 | // get key1 |
135 | key = interfaces->getInterfaceOption("wlan_ng_key1", error).simplifyWhiteSpace(); | 135 | key = interfaces->getInterfaceOption("wlan_ng_key1", error).simplifyWhiteSpace(); |
136 | key.replace(QString(":"),QString("")); | 136 | key.replace(QString(":"),QString("")); |
137 | keyLineEdit1->setText(key); | 137 | keyLineEdit1->setText(key); |
138 | 138 | ||
139 | // get key2 | 139 | // get key2 |
140 | key = interfaces->getInterfaceOption("wlan_ng_key2", error).simplifyWhiteSpace(); | 140 | key = interfaces->getInterfaceOption("wlan_ng_key2", error).simplifyWhiteSpace(); |
141 | key.replace(QString(":"),QString("")); | 141 | key.replace(QString(":"),QString("")); |
142 | keyLineEdit2->setText(key); | 142 | keyLineEdit2->setText(key); |
143 | 143 | ||
144 | // get key3 | 144 | // get key3 |
145 | key = interfaces->getInterfaceOption("wlan_ng_key3", error).simplifyWhiteSpace(); | 145 | key = interfaces->getInterfaceOption("wlan_ng_key3", error).simplifyWhiteSpace(); |
146 | key.replace(QString(":"),QString("")); | 146 | key.replace(QString(":"),QString("")); |
147 | keyLineEdit3->setText(key); | 147 | keyLineEdit3->setText(key); |
148 | 148 | ||
149 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 149 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
150 | 150 | ||
151 | // encryption on? | 151 | // encryption on? |
152 | if(opt == "on"){ | 152 | if(opt == "on"){ |
153 | wepEnabled->setChecked(true); | 153 | wepEnabled->setChecked(true); |
154 | } else { | 154 | } else { |
155 | wepEnabled->setChecked(false); | 155 | wepEnabled->setChecked(false); |
156 | } | 156 | } |
157 | 157 | ||
158 | opt = interfaces->getInterfaceOption("wireless_keymode", error).simplifyWhiteSpace(); | 158 | opt = interfaces->getInterfaceOption("wireless_keymode", error).simplifyWhiteSpace(); |
159 | 159 | ||
160 | if(opt == "restricted"){ | 160 | if(opt == "restricted"){ |
161 | // restricted mode, only accept encrypted packets | 161 | // restricted mode, only accept encrypted packets |
162 | rejectNonEnc->setChecked(true); | 162 | rejectNonEnc->setChecked(true); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 166 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
167 | 167 | ||
168 | parseKeyStr(opt); | 168 | parseKeyStr(opt); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void WLANImp::parseKeyStr(QString keystr) { | 172 | void WLANImp::parseKeyStr(QString keystr) { |
173 | int index = 1; | 173 | int index = 1; |
174 | QString key; | 174 | QString key; |
175 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 175 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
176 | int enc = -1; // encryption state | 176 | int enc = -1; // encryption state |
177 | 177 | ||
178 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 178 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
179 | if ((*it).left(3) == "off") { | 179 | if ((*it).left(3) == "off") { |
180 | // encryption disabled | 180 | // encryption disabled |
181 | enc = 0; | 181 | enc = 0; |
182 | } else if ((*it).left(2) == "on") { | 182 | } else if ((*it).left(2) == "on") { |
183 | // encryption enabled | 183 | // encryption enabled |
184 | enc = 1; | 184 | enc = 1; |
185 | } else if ((*it).left(4) == "open") { | 185 | } else if ((*it).left(4) == "open") { |
186 | // open mode, accept non encrypted packets | 186 | // open mode, accept non encrypted packets |
187 | acceptNonEnc->setChecked(true); | 187 | acceptNonEnc->setChecked(true); |
188 | } else if ((*it).left(10) == "restricted") { | 188 | } else if ((*it).left(10) == "restricted") { |
189 | // restricted mode, only accept encrypted packets | 189 | // restricted mode, only accept encrypted packets |
190 | rejectNonEnc->setChecked(true); | 190 | rejectNonEnc->setChecked(true); |
191 | } else if ((*it).left(3) == "key") { | 191 | } else if ((*it).left(3) == "key") { |
192 | // new set of options | 192 | // new set of options |
193 | } else if ((*it).left(1) == "[") { | 193 | } else if ((*it).left(1) == "[") { |
194 | index = (*it).mid(1, 1).toInt(); | 194 | index = (*it).mid(1, 1).toInt(); |
195 | // switch current key to index | 195 | // switch current key to index |
196 | switch (index) { | 196 | switch (index) { |
197 | case 1: | 197 | case 1: |
198 | keyRadio0->setChecked(true); | 198 | keyRadio0->setChecked(true); |
199 | break; | 199 | break; |
200 | case 2: | 200 | case 2: |
201 | keyRadio1->setChecked(true); | 201 | keyRadio1->setChecked(true); |
202 | break; | 202 | break; |
203 | case 3: | 203 | case 3: |
204 | keyRadio2->setChecked(true); | 204 | keyRadio2->setChecked(true); |
205 | break; | 205 | break; |
206 | case 4: | 206 | case 4: |
207 | keyRadio3->setChecked(true); | 207 | keyRadio3->setChecked(true); |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | } else { | 210 | } else { |
211 | // key | 211 | // key |
212 | key = (*it); | 212 | key = (*it); |
213 | } | 213 | } |
214 | if (! key.isNull()) { | 214 | if (! key.isNull()) { |
215 | if (enc == -1) | 215 | if (enc == -1) |
216 | enc = 1; | 216 | enc = 1; |
217 | QStringList::Iterator next = ++it; | 217 | QStringList::Iterator next = ++it; |
218 | if (it == keys.end()) { | 218 | if (it == keys.end()) { |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | if ((*(next)).left(1) == "[") { | 221 | if ((*(next)).left(1) == "[") { |
222 | // set key at index | 222 | // set key at index |
223 | index = (*(next)).mid(1, 1).toInt(); | 223 | index = (*(next)).mid(1, 1).toInt(); |
224 | } else { | 224 | } else { |
225 | index = 1; | 225 | index = 1; |
226 | } | 226 | } |
227 | switch (index) { | 227 | switch (index) { |
228 | case 1: | 228 | case 1: |
229 | keyLineEdit0->setText(key); | 229 | keyLineEdit0->setText(key); |
230 | break; | 230 | break; |
231 | case 2: | 231 | case 2: |
232 | keyLineEdit1->setText(key); | 232 | keyLineEdit1->setText(key); |
233 | break; | 233 | break; |
234 | case 3: | 234 | case 3: |
235 | keyLineEdit2->setText(key); | 235 | keyLineEdit2->setText(key); |
236 | break; | 236 | break; |
237 | case 4: | 237 | case 4: |
238 | keyLineEdit3->setText(key); | 238 | keyLineEdit3->setText(key); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | key = QString::null; | 241 | key = QString::null; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | if (enc == 1) { | 244 | if (enc == 1) { |
245 | wepEnabled->setChecked(true); | 245 | wepEnabled->setChecked(true); |
246 | } else { | 246 | } else { |
247 | wepEnabled->setChecked(false); | 247 | wepEnabled->setChecked(false); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | /** | 251 | /** |
252 | * Check to see if the current config is valid | 252 | * Check to see if the current config is valid |
253 | * Save interfaces | 253 | * Save interfaces |
254 | */ | 254 | */ |
255 | void WLANImp::accept() { | 255 | void WLANImp::accept() { |
256 | if (wepEnabled->isChecked()) { | 256 | if (wepEnabled->isChecked()) { |
257 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 257 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
258 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 258 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
259 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 259 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
260 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 260 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
261 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 261 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
262 | return; | 262 | return; |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | if (essid->currentText().isEmpty()) { | 266 | if (essid->currentText().isEmpty()) { |
267 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 267 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | 270 | ||
271 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 271 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
272 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 272 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
273 | return; | 273 | return; |
274 | } | 274 | } |
275 | 275 | ||
276 | // Try to save the interfaces settings. | 276 | // Try to save the interfaces settings. |
277 | writeOpts(); | 277 | writeOpts(); |
278 | 278 | ||
279 | // Close out the dialog | 279 | // Close out the dialog |
280 | // FIXME: QDialog::accept(); | 280 | // FIXME: QDialog::accept(); |
281 | } | 281 | } |
282 | 282 | ||
283 | QString WLANImp::formatKey(QString input) | 283 | QString WLANImp::formatKey(QString input) |
284 | { | 284 | { |
285 | int len,r=0; | 285 | int len,r=0; |
286 | 286 | ||
287 | len = input.length(); | 287 | len = input.length(); |
288 | 288 | ||
289 | if (!len) | 289 | if (!len) |
290 | return input; | 290 | return input; |
291 | 291 | ||
292 | for(int i=1;i<len/2;i++) | 292 | for(int i=1;i<len/2;i++) |
293 | { | 293 | { |
294 | input.insert(r+i*2,QString(":")); | 294 | input.insert(r+i*2,QString(":")); |
295 | r++; | 295 | r++; |
296 | } | 296 | } |
297 | 297 | ||
298 | return input; | 298 | return input; |
299 | } | 299 | } |
300 | 300 | ||
301 | void WLANImp::writeOpts() { | 301 | void WLANImp::writeOpts() { |
302 | QString para, devicetype; | 302 | QString para, devicetype; |
303 | 303 | ||
304 | // eh can't really do anything about it other then return. :-D | 304 | // eh can't really do anything about it other then return. :-D |
305 | if(!interfaces->isInterfaceSet()){ | 305 | if(!interfaces->isInterfaceSet()){ |
306 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 306 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | bool error = false; | 309 | bool error = false; |
310 | 310 | ||
311 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; | 311 | odebug << "setting wlan interface " << interfaces->getInterfaceName( error ).latin1() << "" << oendl; |
312 | 312 | ||
313 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 313 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
314 | 314 | ||
315 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 315 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
316 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 316 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
317 | 317 | ||
318 | if (specifyAp->isChecked()) { | 318 | if (specifyAp->isChecked()) { |
319 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 319 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
320 | } else { | 320 | } else { |
321 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 321 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
322 | } | 322 | } |
323 | 323 | ||
324 | if (specifyChan->isChecked()) { | 324 | if (specifyChan->isChecked()) { |
325 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); | 325 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); |
326 | } else { | 326 | } else { |
327 | interfaces->removeInterfaceOption(QString("wireless_channel")); | 327 | interfaces->removeInterfaceOption(QString("wireless_channel")); |
328 | } | 328 | } |
329 | 329 | ||
330 | devicetype = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); | 330 | devicetype = interfaces->getInterfaceOption("wireless_type", error).simplifyWhiteSpace(); |
331 | 331 | ||
332 | if ( devicetype == "wlan-ng") { | 332 | if ( devicetype == "wlan-ng") { |
333 | 333 | ||
334 | // wlan-ng style | 334 | // wlan-ng style |
335 | interfaces->removeInterfaceOption(QString("wireless_key")); | 335 | interfaces->removeInterfaceOption(QString("wireless_key")); |
336 | 336 | ||
337 | if (wepEnabled->isChecked()) { | 337 | if (wepEnabled->isChecked()) { |
338 | 338 | ||
339 | interfaces->setInterfaceOption(QString("wireless_enc"),"on"); | 339 | interfaces->setInterfaceOption(QString("wireless_enc"),"on"); |
340 | 340 | ||
341 | if (! keyLineEdit0->text().isNull()) { | 341 | if (! keyLineEdit0->text().isNull()) { |
342 | interfaces->setInterfaceOption(QString("wlan_ng_key0"), formatKey(keyLineEdit0->text())); | 342 | interfaces->setInterfaceOption(QString("wlan_ng_key0"), formatKey(keyLineEdit0->text())); |
343 | } else | 343 | } else |
344 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); | 344 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); |
345 | if (! keyLineEdit1->text().isNull()) { | 345 | if (! keyLineEdit1->text().isNull()) { |
346 | interfaces->setInterfaceOption(QString("wlan_ng_key1"), formatKey(keyLineEdit1->text())); | 346 | interfaces->setInterfaceOption(QString("wlan_ng_key1"), formatKey(keyLineEdit1->text())); |
347 | } else | 347 | } else |
348 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); | 348 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); |
349 | if (! keyLineEdit2->text().isNull()) { | 349 | if (! keyLineEdit2->text().isNull()) { |
350 | interfaces->setInterfaceOption(QString("wlan_ng_key2"), formatKey(keyLineEdit2->text())); | 350 | interfaces->setInterfaceOption(QString("wlan_ng_key2"), formatKey(keyLineEdit2->text())); |
351 | } else | 351 | } else |
352 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | 352 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); |
353 | if (! keyLineEdit3->text().isNull()) { | 353 | if (! keyLineEdit3->text().isNull()) { |
354 | interfaces->setInterfaceOption(QString("wlan_ng_key3"), formatKey(keyLineEdit3->text())); | 354 | interfaces->setInterfaceOption(QString("wlan_ng_key3"), formatKey(keyLineEdit3->text())); |
355 | } else | 355 | } else |
356 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | 356 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); |
357 | 357 | ||
358 | if (acceptNonEnc->isChecked()) | 358 | if (acceptNonEnc->isChecked()) |
359 | interfaces->removeInterfaceOption(QString("wireless_keymode")); | 359 | interfaces->removeInterfaceOption(QString("wireless_keymode")); |
360 | else | 360 | else |
361 | interfaces->setInterfaceOption(QString("wireless_keymode"),"restricted"); | 361 | interfaces->setInterfaceOption(QString("wireless_keymode"),"restricted"); |
362 | 362 | ||
363 | para = ""; | 363 | para = ""; |
364 | if (keyRadio0->isChecked()) { | 364 | if (keyRadio0->isChecked()) { |
365 | para = "0"; | 365 | para = "0"; |
366 | } else if (keyRadio1->isChecked()) { | 366 | } else if (keyRadio1->isChecked()) { |
367 | para = "1"; | 367 | para = "1"; |
368 | } else if (keyRadio2->isChecked()) { | 368 | } else if (keyRadio2->isChecked()) { |
369 | para = "2"; | 369 | para = "2"; |
370 | } else if (keyRadio3->isChecked()) { | 370 | } else if (keyRadio3->isChecked()) { |
371 | para = "3"; | 371 | para = "3"; |
372 | } | 372 | } |
373 | 373 | ||
374 | interfaces->setInterfaceOption(QString("wlan_ng_default_key_id"), para); | 374 | interfaces->setInterfaceOption(QString("wlan_ng_default_key_id"), para); |
375 | 375 | ||
376 | } else { | 376 | } else { |
377 | // No wep, remove all previous keys | 377 | // No wep, remove all previous keys |
378 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 378 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
379 | interfaces->removeInterfaceOption(QString("wlan_ng_default_key_id")); | 379 | interfaces->removeInterfaceOption(QString("wlan_ng_default_key_id")); |
380 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); | 380 | interfaces->removeInterfaceOption(QString("wlan_ng_key0")); |
381 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); | 381 | interfaces->removeInterfaceOption(QString("wlan_ng_key1")); |
382 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); | 382 | interfaces->removeInterfaceOption(QString("wlan_ng_key2")); |
383 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); | 383 | interfaces->removeInterfaceOption(QString("wlan_ng_key3")); |
384 | } | 384 | } |
385 | 385 | ||
386 | } else { | 386 | } else { |
387 | // This is the old style | 387 | // This is the old style |
388 | if (wepEnabled->isChecked()) { | 388 | if (wepEnabled->isChecked()) { |
389 | QStringList keyList; | 389 | QStringList keyList; |
390 | 390 | ||
391 | if (! keyLineEdit0->text().isNull()) { | 391 | if (! keyLineEdit0->text().isNull()) { |
392 | keyList += keyLineEdit0->text(); | 392 | keyList += keyLineEdit0->text(); |
393 | keyList += "[1]"; | 393 | keyList += "[1]"; |
394 | } //else | 394 | } //else |
395 | if (! keyLineEdit1->text().isNull()) { | 395 | if (! keyLineEdit1->text().isNull()) { |
396 | keyList += keyLineEdit1->text(); | 396 | keyList += keyLineEdit1->text(); |
397 | keyList += "[2]"; | 397 | keyList += "[2]"; |
398 | } //else | 398 | } //else |
399 | if (! keyLineEdit2->text().isNull()) { | 399 | if (! keyLineEdit2->text().isNull()) { |
400 | keyList += keyLineEdit2->text(); | 400 | keyList += keyLineEdit2->text(); |
401 | keyList += "[3]"; | 401 | keyList += "[3]"; |
402 | } //else | 402 | } //else |
403 | if (! keyLineEdit3->text().isNull()) { | 403 | if (! keyLineEdit3->text().isNull()) { |
404 | keyList += keyLineEdit3->text(); | 404 | keyList += keyLineEdit3->text(); |
405 | keyList += "[4]"; | 405 | keyList += "[4]"; |
406 | } | 406 | } |
407 | if (acceptNonEnc->isChecked()) { | 407 | if (acceptNonEnc->isChecked()) { |
408 | keyList += "open"; | 408 | keyList += "open"; |
409 | } else { | 409 | } else { |
410 | keyList += "restricted"; | 410 | keyList += "restricted"; |
411 | } | 411 | } |
412 | 412 | ||
413 | keyList += "key"; | 413 | keyList += "key"; |
414 | if (keyRadio0->isChecked()) { | 414 | if (keyRadio0->isChecked()) { |
415 | keyList += "[1]"; | 415 | keyList += "[1]"; |
416 | } else if (keyRadio1->isChecked()) { | 416 | } else if (keyRadio1->isChecked()) { |
417 | keyList += "[2]"; | 417 | keyList += "[2]"; |
418 | } else if (keyRadio2->isChecked()) { | 418 | } else if (keyRadio2->isChecked()) { |
419 | keyList += "[3]"; | 419 | keyList += "[3]"; |
420 | } else if (keyRadio3->isChecked()) { | 420 | } else if (keyRadio3->isChecked()) { |
421 | keyList += "[4]"; | 421 | keyList += "[4]"; |
422 | } | 422 | } |
423 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | 423 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); |
424 | } else { | 424 | } else { |
425 | interfaces->removeInterfaceOption(QString("wireless_key")); | 425 | interfaces->removeInterfaceOption(QString("wireless_key")); |
426 | } | 426 | } |
427 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 427 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
428 | } | 428 | } |
429 | 429 | ||
430 | if(!interfaceSetup->saveChanges()) | 430 | if(!interfaceSetup->saveChanges()) |
431 | return; | 431 | return; |
432 | 432 | ||
433 | QDialog::accept(); | 433 | QDialog::accept(); |
434 | } | 434 | } |
435 | 435 | ||
436 | /* | 436 | /* |
437 | * Scan for possible wireless networks around... | 437 | * Scan for possible wireless networks around... |
438 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> | 438 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> |
439 | */ | 439 | */ |
440 | 440 | ||
441 | void WLANImp::rescanNeighbourhood() | 441 | void WLANImp::rescanNeighbourhood() |
442 | { | 442 | { |
443 | QString name = interface->getInterfaceName(); | 443 | QString name = interface->getInterfaceName(); |
444 | odebug << "rescanNeighbourhood via '" << name << "'" << oendl; | 444 | odebug << "rescanNeighbourhood via '" << name << "'" << oendl; |
445 | 445 | ||
446 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); | 446 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); |
447 | assert( wiface ); | 447 | assert( wiface ); |
448 | 448 | ||
449 | // try to guess device type | 449 | // try to guess device type |
450 | QString devicetype; | 450 | QString devicetype; |
451 | QFile m( "/proc/modules" ); | 451 | QFile m( "/proc/modules" ); |
452 | if ( m.open( IO_ReadOnly ) ) | 452 | if ( m.open( IO_ReadOnly ) ) |
453 | { | 453 | { |
454 | QString line; | 454 | QString line; |
455 | QTextStream modules( &m ); | 455 | QTextStream modules( &m ); |
456 | while( !modules.atEnd() && !devicetype ) | 456 | while( !modules.atEnd() && !devicetype ) |
457 | { | 457 | { |
458 | modules >> line; | 458 | modules >> line; |
459 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; | 459 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; |
460 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; | 460 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; |
461 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ | 461 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ |
462 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; | 462 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | if ( devicetype.isEmpty() ) | 465 | if ( devicetype.isEmpty() ) |
466 | { | 466 | { |
467 | owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; | 467 | owarn << "rescanNeighbourhood(): couldn't guess device type :(" << oendl; |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | else | 470 | else |
471 | { | 471 | { |
472 | odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; | 472 | odebug << "rescanNeighbourhood(): device type seems to be '" << devicetype << "'" << oendl; |
473 | } | 473 | } |
474 | 474 | ||
475 | // configure interface to receive 802.11 management frames | 475 | // configure interface to receive 802.11 management frames |
476 | 476 | ||
477 | wiface->setUp( true ); | 477 | wiface->setUp( true ); |
478 | wiface->setPromiscuousMode( true ); | 478 | wiface->setPromiscuousMode( true ); |
479 | 479 | ||
480 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); | 480 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); |
481 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); | 481 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); |
482 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); | 482 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); |
483 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); | 483 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); |
484 | else | 484 | else |
485 | { | 485 | { |
486 | odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; | 486 | odebug << "rescanNeighbourhood(): unsupported device type for monitoring :(" << oendl; |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | 489 | ||
490 | wiface->setMode( "monitor" ); | 490 | wiface->setMode( "monitor" ); |
491 | if ( wiface->mode() != "monitor" ) | 491 | if ( wiface->mode() != "monitor" ) |
492 | { | 492 | { |
493 | owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; | 493 | owarn << "rescanNeighbourhood(): Unable to bring device into monitor mode (" << strerror( errno ) << ")." << oendl; |
494 | return; | 494 | return; |
495 | } | 495 | } |
496 | 496 | ||
497 | // open a packet capturer | 497 | // open a packet capturer |
498 | OPacketCapturer* cap = new OPacketCapturer(); | 498 | OPacketCapturer* cap = new OPacketCapturer(); |
499 | cap->open( name ); | 499 | cap->open( name ); |
500 | if ( !cap->isOpen() ) | 500 | if ( !cap->isOpen() ) |
501 | { | 501 | { |
502 | owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; | 502 | owarn << "rescanNeighbourhood(): Unable to open libpcap (" << strerror( errno ) << ")." << oendl; |
503 | return; | 503 | return; |
504 | } | 504 | } |
505 | 505 | ||
506 | // disable button and display splash screen | 506 | // disable button and display splash screen |
507 | rescanButton->setEnabled( false ); | 507 | rescanButton->setEnabled( false ); |
508 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); | 508 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); |
509 | splash->setLineWidth( 2 ); | 509 | splash->setLineWidth( 2 ); |
510 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); | 510 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); |
511 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); | 511 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); |
512 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); | 512 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); |
513 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); | 513 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); |
514 | vbox->addWidget( lab ); | 514 | vbox->addWidget( lab ); |
515 | vbox->addWidget( pb ); | 515 | vbox->addWidget( pb ); |
516 | pb->setCenterIndicator( true ); | 516 | pb->setCenterIndicator( true ); |
517 | pb->setFixedHeight( pb->sizeHint().height() ); | 517 | pb->setFixedHeight( pb->sizeHint().height() ); |
518 | QWidget* widgetDesktop = qApp->desktop(); | 518 | QWidget* widgetDesktop = qApp->desktop(); |
519 | int dw = widgetDesktop->width(); | 519 | int dw = widgetDesktop->width(); |
520 | int dh = widgetDesktop->height(); | 520 | int dh = widgetDesktop->height(); |
521 | int pw = vbox->sizeHint().width(); | 521 | int pw = vbox->sizeHint().width(); |
522 | int ph = vbox->sizeHint().height(); | 522 | int ph = vbox->sizeHint().height(); |
523 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); | 523 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); |
524 | splash->show(); | 524 | splash->show(); |
525 | splash->raise(); | 525 | splash->raise(); |
526 | qApp->processEvents(); | 526 | qApp->processEvents(); |
527 | 527 | ||
528 | // set capturer to non-blocking mode | 528 | // set capturer to non-blocking mode |
529 | cap->setBlocking( false ); | 529 | cap->setBlocking( false ); |
530 | 530 | ||
531 | for ( int i = 1; i <= wiface->channels(); ++i ) | 531 | for ( int i = 1; i <= wiface->channels(); ++i ) |
532 | { | 532 | { |
533 | wiface->setChannel( i ); | 533 | wiface->setChannel( i ); |
534 | pb->setProgress( i ); | 534 | pb->setProgress( i ); |
535 | qApp->processEvents(); | 535 | qApp->processEvents(); |
536 | odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; | 536 | odebug << "rescanNeighbourhood(): listening on channel " << i << "..." << oendl; |
537 | OPacket* p = cap->next( 1000 ); | 537 | OPacket* p = cap->next( 1000 ); |
538 | if ( !p ) | 538 | if ( !p ) |
539 | { | 539 | { |
540 | odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; | 540 | odebug << "rescanNeighbourhood(): nothing received on channel " << i << "" << oendl; |
541 | } | 541 | } |
542 | else | 542 | else |
543 | { | 543 | { |
544 | odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; | 544 | odebug << "rescanNeighbourhood(): TADAA - something came in on channel " << i << "" << oendl; |
545 | handlePacket( p ); | 545 | handlePacket( p ); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | cap->close(); | 549 | cap->close(); |
550 | wiface->setMode( "managed" ); // TODO: use previous mode | 550 | wiface->setMode( "managed" ); // TODO: use previous mode |
551 | wiface->setPromiscuousMode( false ); | 551 | wiface->setPromiscuousMode( false ); |
552 | 552 | ||
553 | // hide splash screen and reenable button | 553 | // hide splash screen and reenable button |
554 | splash->hide(); | 554 | splash->hide(); |
555 | delete splash; | 555 | delete splash; |
556 | rescanButton->setEnabled( true ); | 556 | rescanButton->setEnabled( true ); |
557 | } | 557 | } |
558 | 558 | ||
559 | void WLANImp::handlePacket( OPacket* p ) | 559 | void WLANImp::handlePacket( OPacket* p ) |
560 | { | 560 | { |
561 | 561 | ||
562 | // check if we received a beacon frame | 562 | // check if we received a beacon frame |
563 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 563 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
564 | if ( beacon && beacon->managementType() == "Beacon" ) | 564 | if ( beacon && beacon->managementType() == "Beacon" ) |
565 | { | 565 | { |
566 | 566 | ||
567 | QString type; | 567 | QString type; |
568 | if ( beacon->canIBSS() ) | 568 | if ( beacon->canIBSS() ) |
569 | { | 569 | { |
570 | type = "adhoc"; | 570 | type = "adhoc"; |
571 | } | 571 | } |
572 | else if ( beacon->canESS() ) | 572 | else if ( beacon->canESS() ) |
573 | { | 573 | { |
574 | type = "managed"; | 574 | type = "managed"; |
575 | } | 575 | } |
576 | else | 576 | else |
577 | { | 577 | { |
578 | owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; | 578 | owarn << "handlePacket(): invalid frame [possibly noise] detected!" << oendl; |
579 | return; | 579 | return; |
580 | } | 580 | } |
581 | 581 | ||
582 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 582 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
583 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 583 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
584 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 584 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
585 | int channel = ds ? ds->channel() : -1; | 585 | int channel = ds ? ds->channel() : -1; |
586 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 586 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
587 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); | 587 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) | 592 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) |
593 | { | 593 | { |
594 | 594 | ||
595 | odebug << "found network: <" << (const char*) mode << ">, chn " << channel | 595 | odebug << "found network: <" << (const char*) mode << ">, chn " << channel |
596 | << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl; | 596 | << ", ssid '" << (const char*) ssid << "', mac '" << (const char*) mac.toString() << "'" << oendl; |
597 | 597 | ||
598 | QListViewItemIterator it( netView ); | 598 | QListViewItemIterator it( netView ); |
599 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; | 599 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; |
600 | if ( !it.current() ) // ssid didn't show up yet | 600 | if ( !it.current() ) // ssid didn't show up yet |
601 | { | 601 | { |
602 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); | 602 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); |
603 | QString name; | 603 | QString name; |
604 | name.sprintf( "networksettings/%s", (const char*) mode ); | 604 | name.sprintf( "networksettings/%s", (const char*) mode ); |
605 | item->setPixmap( col_mode, Resource::loadPixmap( name ) ); | 605 | item->setPixmap( col_mode, Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) ); |
606 | qApp->processEvents(); | 606 | qApp->processEvents(); |
607 | } | 607 | } |
608 | 608 | ||
609 | } | 609 | } |
610 | 610 | ||
611 | 611 | ||
612 | void WLANImp::selectNetwork( QListViewItem* item ) | 612 | void WLANImp::selectNetwork( QListViewItem* item ) |
613 | { | 613 | { |
614 | bool ok; | 614 | bool ok; |
615 | if ( item ) | 615 | if ( item ) |
616 | { | 616 | { |
617 | specifyAp->setChecked(true); | 617 | specifyAp->setChecked(true); |
618 | macEdit->setText( item->text( col_mac ) ); | 618 | macEdit->setText( item->text( col_mac ) ); |
619 | specifyChan->setChecked( item->text( col_mode ) == "A" ); | 619 | specifyChan->setChecked( item->text( col_mode ) == "A" ); |
620 | networkChannel->setValue( item->text( col_chn ).toInt( &ok ) ); | 620 | networkChannel->setValue( item->text( col_chn ).toInt( &ok ) ); |
621 | essid->setEditText( item->text( col_ssid ) ); | 621 | essid->setEditText( item->text( col_ssid ) ); |
622 | if ( item->text( col_mode ) == "A" ) | 622 | if ( item->text( col_mode ) == "A" ) |
623 | mode->setCurrentItem( 3 ); | 623 | mode->setCurrentItem( 3 ); |
624 | else | 624 | else |
625 | mode->setCurrentItem( 2 ); | 625 | mode->setCurrentItem( 2 ); |
626 | } | 626 | } |
627 | } | 627 | } |