summaryrefslogtreecommitdiff
authortille <tille>2003-05-25 00:51:44 (UTC)
committer tille <tille>2003-05-25 00:51:44 (UTC)
commitf6d835c4846f48d33f0ba9e86707c4ec23544182 (patch) (unidiff)
tree65d9019f52445054331ba3a30277ca41abb0feca
parent672a9a2ecd1132aadcf1043946e27339693145a4 (diff)
downloadopie-f6d835c4846f48d33f0ba9e86707c4ec23544182.zip
opie-f6d835c4846f48d33f0ba9e86707c4ec23544182.tar.gz
opie-f6d835c4846f48d33f0ba9e86707c4ec23544182.tar.bz2
ask plugins for interfaces...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index a61f620..63b9603 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -152,16 +152,17 @@ void MainWindowImp::getAllInterfaces(){
152 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 152 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
153 if(sockfd == -1) 153 if(sockfd == -1)
154 return; 154 return;
155 155
156 struct ifreq ifr; 156 struct ifreq ifr;
157 QStringList ifaces; 157 QStringList ifaces;
158 QFile procFile(QString(_PROCNETDEV)); 158 QFile procFile(QString(_PROCNETDEV));
159 int result; 159 int result;
160 Interface *i;
160 161
161 if (! procFile.exists()) { 162 if (! procFile.exists()) {
162 struct ifreq ifrs[100]; 163 struct ifreq ifrs[100];
163 struct ifconf ifc; 164 struct ifconf ifc;
164 ifc.ifc_len = sizeof(ifrs); 165 ifc.ifc_len = sizeof(ifrs);
165 ifc.ifc_req = ifrs; 166 ifc.ifc_req = ifrs;
166 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 167 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
167 168
@@ -182,17 +183,17 @@ void MainWindowImp::getAllInterfaces(){
182 if((loc = line.find(":")) != -1) { 183 if((loc = line.find(":")) != -1) {
183 ifaces += line.left(loc); 184 ifaces += line.left(loc);
184 } 185 }
185 } 186 }
186 } 187 }
187 188
188 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 189 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
189 int flags = 0, family; 190 int flags = 0, family;
190 Interface *i = NULL; 191 i = NULL;
191 192
192 strcpy(ifr.ifr_name, (*it).latin1()); 193 strcpy(ifr.ifr_name, (*it).latin1());
193 194
194 struct ifreq ifcopy; 195 struct ifreq ifcopy;
195 ifcopy = ifr; 196 ifcopy = ifr;
196 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 197 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
197 flags = ifcopy.ifr_flags; 198 flags = ifcopy.ifr_flags;
198 i = new Interface(this, ifr.ifr_name, false); 199 i = new Interface(this, ifr.ifr_name, false);
@@ -211,17 +212,33 @@ void MainWindowImp::getAllInterfaces(){
211 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 212 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
212 i->setHardwareName("Loopback"); 213 i->setHardwareName("Loopback");
213 else 214 else
214 i->setHardwareName("Unknown"); 215 i->setHardwareName("Unknown");
215 216
216 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 217 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
217 interfaceNames.insert(i->getInterfaceName(), i); 218 interfaceNames.insert(i->getInterfaceName(), i);
218 updateInterface(i); 219 updateInterface(i);
219 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 220 connect(i, SIGNAL(updateInterface(Interface *)),
221 this, SLOT(updateInterface(Interface *)));
222 }
223 // now lets ask the plugins too ;)
224 QMap<Module*, QLibrary*>::Iterator it;
225 QList<Interface> ilist;
226 for( it = libraries.begin(); it != libraries.end(); ++it ){
227 if(it.key()){
228 ilist = it.key()->getInterfaces();
229 for( i = ilist.first(); i != 0; i = ilist.next() ){
230 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
231 interfaceNames.insert(i->getInterfaceName(), i);
232 updateInterface(i);
233 connect(i, SIGNAL(updateInterface(Interface *)),
234 this, SLOT(updateInterface(Interface *)));
235 }
236 }
220 } 237 }
221} 238}
222 239
223/** 240/**
224 * Load all modules that are found in the path 241 * Load all modules that are found in the path
225 * @param path a directory that is scaned for any plugins that can be loaded 242 * @param path a directory that is scaned for any plugins that can be loaded
226 * and attempts to load them 243 * and attempts to load them
227 */ 244 */
@@ -311,18 +328,17 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &
311/** 328/**
312 * The Add button was clicked. Bring up the add dialog and if OK is hit 329 * The Add button was clicked. Bring up the add dialog and if OK is hit
313 * load the plugin and append it to the list 330 * load the plugin and append it to the list
314 */ 331 */
315void MainWindowImp::addClicked(){ 332void MainWindowImp::addClicked(){
316 QMap<Module*, QLibrary*>::Iterator it; 333 QMap<Module*, QLibrary*>::Iterator it;
317 QMap<QString, QString> list; 334 QMap<QString, QString> list;
318 QMap<QString, Module*> newInterfaceOwners; 335 QMap<QString, Module*> newInterfaceOwners;
319 //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 336
320 //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
321 for( it = libraries.begin(); it != libraries.end(); ++it ){ 337 for( it = libraries.begin(); it != libraries.end(); ++it ){
322 if(it.key()){ 338 if(it.key()){
323 (it.key())->possibleNewInterfaces(list); 339 (it.key())->possibleNewInterfaces(list);
324 } 340 }
325 } 341 }
326 // See if the list has anything that we can add. 342 // See if the list has anything that we can add.
327 if(list.count() == 0){ 343 if(list.count() == 0){
328 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 344 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);