summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index e34f0ce..371b689 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,213 +1,215 @@
1#include "wlanmodule.h" 1#include "wlanmodule.h"
2#include "wlanimp.h" 2#include "wlanimp.h"
3#include "infoimp.h" 3#include "infoimp.h"
4#include "wextensions.h" 4#include "wextensions.h"
5#include "interfaceinformationimp.h" 5#include "interfaceinformationimp.h"
6 6
7#include <qcheckbox.h> 7#include <qcheckbox.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qprogressbar.h> 11#include <qprogressbar.h>
12#include <qspinbox.h> 12#include <qspinbox.h>
13#include <qtabwidget.h> 13#include <qtabwidget.h>
14 14
15 15
16 16
17 17
18/** 18/**
19 * Constructor, find all of the possible interfaces 19 * Constructor, find all of the possible interfaces
20 */ 20 */
21WLANModule::WLANModule() 21WLANModule::WLANModule()
22 : Module(), 22 : Module(),
23 wlanconfigWiget(0) 23 wlanconfigWiget(0)
24{ 24{
25} 25}
26 26
27/** 27/**
28 * Delete any interfaces that we own. 28 * Delete any interfaces that we own.
29 */ 29 */
30WLANModule::~WLANModule(){ 30WLANModule::~WLANModule(){
31 Interface *i; 31 Interface *i;
32 for ( i=list.first(); i != 0; i=list.next() ) 32 for ( i=list.first(); i != 0; i=list.next() )
33 delete i; 33 delete i;
34 34
35} 35}
36 36
37/** 37/**
38 * Change the current profile 38 * Change the current profile
39 */ 39 */
40void WLANModule::setProfile(const QString &newProfile){ 40void WLANModule::setProfile(const QString &newProfile){
41 profile = newProfile; 41 profile = newProfile;
42} 42}
43 43
44/** 44/**
45 * get the icon name for this device. 45 * get the icon name for this device.
46 * @param Interface* can be used in determining the icon. 46 * @param Interface* can be used in determining the icon.
47 * @return QString the icon name (minus .png, .gif etc) 47 * @return QString the icon name (minus .png, .gif etc)
48 */ 48 */
49QString WLANModule::getPixmapName(Interface* ){ 49QString WLANModule::getPixmapName(Interface* ){
50 return "wlan"; 50 return "wlan";
51} 51}
52 52
53/** 53/**
54 * Check to see if the interface i is owned by this module. 54 * Check to see if the interface i is owned by this module.
55 * @param Interface* interface to check against 55 * @param Interface* interface to check against
56 * @return bool true if i is owned by this module, false otherwise. 56 * @return bool true if i is owned by this module, false otherwise.
57 */ 57 */
58bool WLANModule::isOwner(Interface *i){ 58bool WLANModule::isOwner(Interface *i){
59 WExtensions we(i->getInterfaceName()); 59 WExtensions we(i->getInterfaceName());
60 if(!we.doesHaveWirelessExtensions()) 60 if(!we.doesHaveWirelessExtensions())
61 return false; 61 return false;
62 62
63 i->setHardwareName("802.11b"); 63 i->setHardwareName("802.11b");
64 list.append(i); 64 list.append(i);
65 return true; 65 return true;
66} 66}
67 67
68/** 68/**
69 * Create, and return the WLANConfigure Module 69 * Create, and return the WLANConfigure Module
70 * @return QWidget* pointer to this modules configure. 70 * @return QWidget* pointer to this modules configure.
71 */ 71 */
72QWidget *WLANModule::configure(Interface *i){ 72QWidget *WLANModule::configure(Interface *i){
73 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); 73 WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
74 wlanconfig->setProfile(profile); 74 wlanconfig->setProfile(profile);
75 return wlanconfig; 75 return wlanconfig;
76} 76}
77 77
78/** 78/**
79 * Create, and return the Information Module 79 * Create, and return the Information Module
80 * @return QWidget* pointer to this modules info. 80 * @return QWidget* pointer to this modules info.
81 */ 81 */
82QWidget *WLANModule::information(Interface *i){ 82QWidget *WLANModule::information(Interface *i){
83 WExtensions we(i->getInterfaceName()); 83 WExtensions we(i->getInterfaceName());
84 if(!we.doesHaveWirelessExtensions()) 84 if(!we.doesHaveWirelessExtensions())
85 return NULL; 85 return NULL;
86 86
87 return getInfo( i ); 87 return getInfo( i );
88} 88}
89 89
90/** 90/**
91 * Get all active (up or down) interfaces 91 * Get all active (up or down) interfaces
92 * @return QList<Interface> A list of interfaces that exsist that havn't 92 * @return QList<Interface> A list of interfaces that exsist that havn't
93 * been called by isOwner() 93 * been called by isOwner()
94 */ 94 */
95QList<Interface> WLANModule::getInterfaces(){ 95QList<Interface> WLANModule::getInterfaces(){
96 return list; 96 return list;
97} 97}
98 98
99/** 99/**
100 * Attempt to add a new interface as defined by name 100 * Attempt to add a new interface as defined by name
101 * @param name the name of the type of interface that should be created given 101 * @param name the name of the type of interface that should be created given
102 * by possibleNewInterfaces(); 102 * by possibleNewInterfaces();
103 * @return Interface* NULL if it was unable to be created. 103 * @return Interface* NULL if it was unable to be created.
104 */ 104 */
105Interface *WLANModule::addNewInterface(const QString &){ 105Interface *WLANModule::addNewInterface(const QString &){
106 // We can't add a 802.11 interface, either the hardware will be there 106 // We can't add a 802.11 interface, either the hardware will be there
107 // or it wont. 107 // or it wont.
108 return NULL; 108 return NULL;
109} 109}
110 110
111/** 111/**
112 * Attempts to remove the interface, doesn't delete i 112 * Attempts to remove the interface, doesn't delete i
113 * @return bool true if successfull, false otherwise. 113 * @return bool true if successfull, false otherwise.
114 */ 114 */
115bool WLANModule::remove(Interface*){ 115bool WLANModule::remove(Interface*){
116 // Can't remove a hardware device, you can stop it though. 116 // Can't remove a hardware device, you can stop it though.
117 return false; 117 return false;
118} 118}
119 119
120void WLANModule::receive(const QCString &param, const QByteArray &arg) 120void WLANModule::receive(const QCString &param, const QByteArray &arg)
121{ 121{
122 qDebug("WLANModule::receive "+param); 122 qDebug("WLANModule::receive "+param);
123 QStringList params = QStringList::split(",",param); 123 QStringList params = QStringList::split(",",param);
124 int count = params.count(); 124 int count = params.count();
125 qDebug("WLANModule got %i params", count ); 125 qDebug("WLANModule got %i params", count );
126 if (count < 2){ 126 if (count < 2){
127 qDebug("Erorr less than 2 parameter"); 127 qDebug("Erorr less than 2 parameter");
128 qDebug("RETURNING"); 128 qDebug("RETURNING");
129 return; 129 return;
130 } 130 }
131 131
132 QDataStream stream(arg,IO_ReadOnly); 132 QDataStream stream(arg,IO_ReadOnly);
133 QString interface; 133 QString interface;
134 QString action; 134 QString action;
135 while (! stream.atEnd() ){ 135 while (! stream.atEnd() ){
136 stream >> interface; 136 stream >> interface;
137 stream >> action; 137 stream >> action;
138 qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); 138 qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1());
139 // find interfaces 139 // find interfaces
140 Interface *ifa=0; 140 Interface *ifa=0;
141 for ( Interface *i=list.first(); i != 0; i=list.next() ){ 141 for ( Interface *i=list.first(); i != 0; i=list.next() ){
142 if (i->getInterfaceName() == interface){ 142 if (i->getInterfaceName() == interface){
143 qDebug("WLANModule found interface %s",interface.latin1()); 143 qDebug("WLANModule found interface %s",interface.latin1());
144 ifa = i; 144 ifa = i;
145 } 145 }
146 } 146 }
147 147
148 if (ifa == 0){ 148 if (ifa == 0){
149 qFatal("WLANModule Did not find %s",interface.latin1()); 149 qDebug("WLANModule Did not find %s",interface.latin1());
150 qDebug("returning");
151 return;
150 } 152 }
151 153
152 if (count == 2){ 154 if (count == 2){
153 // those should call the interface directly 155 // those should call the interface directly
154 QWidget *info = getInfo( ifa ); 156 QWidget *info = getInfo( ifa );
155 info->showMaximized(); 157 info->showMaximized();
156 158
157 if ( action.contains("start" ) ){ 159 if ( action.contains("start" ) ){
158 ifa->start(); 160 ifa->start();
159 } else if ( action.contains("restart" ) ){ 161 } else if ( action.contains("restart" ) ){
160 ifa->restart(); 162 ifa->restart();
161 } else if ( action.contains("stop" ) ){ 163 } else if ( action.contains("stop" ) ){
162 ifa->stop(); 164 ifa->stop();
163 }else if ( action.contains("refresh" ) ){ 165 }else if ( action.contains("refresh" ) ){
164 ifa->refresh(); 166 ifa->refresh();
165 } 167 }
166 }else if (count == 3){ 168 }else if (count == 3){
167 QString value; 169 QString value;
168 if (!wlanconfigWiget){ 170 if (!wlanconfigWiget){
169 //FIXME: what if it got closed meanwhile? 171 //FIXME: what if it got closed meanwhile?
170 wlanconfigWiget = (WLANImp*) configure(ifa); 172 wlanconfigWiget = (WLANImp*) configure(ifa);
171 } 173 }
172 wlanconfigWiget->showMaximized(); 174 wlanconfigWiget->showMaximized();
173 stream >> value; 175 stream >> value;
174 qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); 176 qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
175 if ( action.contains("ESSID") ){ 177 if ( action.contains("ESSID") ){
176 QComboBox *combo = wlanconfigWiget->essid; 178 QComboBox *combo = wlanconfigWiget->essid;
177 bool found = false; 179 bool found = false;
178 for ( int i = 0; i < combo->count(); i++) 180 for ( int i = 0; i < combo->count(); i++)
179 if ( combo->text( i ) == value ){ 181 if ( combo->text( i ) == value ){
180 combo->setCurrentItem( i ); 182 combo->setCurrentItem( i );
181 found = true; 183 found = true;
182 } 184 }
183 if (!found) combo->insertItem( value, 0 ); 185 if (!found) combo->insertItem( value, 0 );
184 }else if ( action.contains("Mode") ){ 186 }else if ( action.contains("Mode") ){
185 QComboBox *combo = wlanconfigWiget->mode; 187 QComboBox *combo = wlanconfigWiget->mode;
186 for ( int i = 0; i < combo->count(); i++) 188 for ( int i = 0; i < combo->count(); i++)
187 if ( combo->text( i ) == value ){ 189 if ( combo->text( i ) == value ){
188 combo->setCurrentItem( i ); 190 combo->setCurrentItem( i );
189 } 191 }
190 192
191 }else if (action.contains("Channel")){ 193 }else if (action.contains("Channel")){
192 wlanconfigWiget->specifyChan->setChecked( true ); 194 wlanconfigWiget->specifyChan->setChecked( true );
193 wlanconfigWiget->networkChannel->setValue( value.toInt() ); 195 wlanconfigWiget->networkChannel->setValue( value.toInt() );
194 }else if (action.contains("MacAddr")){ 196 }else if (action.contains("MacAddr")){
195 wlanconfigWiget->specifyAp->setChecked( true ); 197 wlanconfigWiget->specifyAp->setChecked( true );
196 wlanconfigWiget->macEdit->setText( value ); 198 wlanconfigWiget->macEdit->setText( value );
197 }else 199 }else
198 qDebug("wlan plugin has no clue"); 200 qDebug("wlan plugin has no clue");
199 } 201 }
200 }// while stream 202 }// while stream
201} 203}
202 204
203QWidget *WLANModule::getInfo( Interface *i) 205QWidget *WLANModule::getInfo( Interface *i)
204{ 206{
205 qDebug("WLANModule::getInfo start"); 207 qDebug("WLANModule::getInfo start");
206 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 208 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
207 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 209 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
208 info->tabWidget->insertTab(information, "TCP/IP", 0); 210 info->tabWidget->insertTab(information, "TCP/IP", 0);
209 211
210 qDebug("WLANModule::getInfo return"); 212 qDebug("WLANModule::getInfo return");
211 return info; 213 return info;
212} 214}
213 215