Diffstat (limited to 'noncore/settings/networksettings/wlan/wlanmodule.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index a4488f9..b4c3509 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,194 +1,194 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp2.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 | */ |
21 | WLANModule::WLANModule() | 21 | WLANModule::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 | */ |
30 | WLANModule::~WLANModule(){ | 30 | WLANModule::~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 | */ |
40 | void WLANModule::setProfile(const QString &newProfile){ | 40 | void 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 | */ |
49 | QString WLANModule::getPixmapName(Interface* ){ | 49 | QString 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 | */ |
58 | bool WLANModule::isOwner(Interface *i){ | 58 | bool 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 | */ |
72 | QWidget *WLANModule::configure(Interface *i){ | 72 | QWidget *WLANModule::configure(Interface *i){ |
73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); | 73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, 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 | */ |
82 | QWidget *WLANModule::information(Interface *i){ | 82 | QWidget *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 | */ |
95 | QList<Interface> WLANModule::getInterfaces(){ | 95 | QList<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 | */ |
105 | Interface *WLANModule::addNewInterface(const QString &){ | 105 | Interface *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 | */ |
115 | bool WLANModule::remove(Interface*){ | 115 | bool 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 | ||
120 | void WLANModule::receive(const QCString ¶m, const QByteArray &arg) | 120 | void WLANModule::receive(const QCString ¶m, 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 | int countMsgs = 0; | 135 | int countMsgs = 0; |
136 | stream >> interface; | 136 | stream >> interface; |
137 | qDebug("got count? >%s<",interface.latin1()); | 137 | qDebug("got count? >%s<",interface.latin1()); |
138 | if (interface == "count"){ | 138 | if (interface == "count"){ |
139 | qDebug("got count"); | 139 | qDebug("got count"); |
140 | stream >> action; | 140 | stream >> action; |
141 | qDebug("Got count num >%s<", action.latin1()); | 141 | qDebug("Got count num >%s<", action.latin1()); |
142 | countMsgs = action.toInt(); | 142 | countMsgs = action.toInt(); |
143 | } | 143 | } |
144 | 144 | ||
145 | QDialog *toShow; | 145 | QDialog *toShow; |
146 | //while (! stream.atEnd() ){ | 146 | //while (! stream.atEnd() ){ |
147 | for (int i = 0; i < countMsgs; i++){ | 147 | for (int i = 0; i < countMsgs; i++){ |
148 | qDebug("start stream %d/%d",i,countMsgs); | 148 | qDebug("start stream %d/%d",i,countMsgs); |
149 | if (stream.atEnd()){ | 149 | if (stream.atEnd()){ |
150 | qDebug("end of stream"); | 150 | qDebug("end of stream"); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | stream >> interface; | 153 | stream >> interface; |
154 | qDebug("got iface"); | 154 | qDebug("got iface"); |
155 | stream >> action; | 155 | stream >> action; |
156 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); | 156 | qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1()); |
157 | // find interfaces | 157 | // find interfaces |
158 | Interface *ifa=0; | 158 | Interface *ifa=0; |
159 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ | 159 | for ( Interface *i=list.first(); i != 0; i=list.next() ){ |
160 | if (i->getInterfaceName() == interface){ | 160 | if (i->getInterfaceName() == interface){ |
161 | qDebug("WLANModule found interface %s",interface.latin1()); | 161 | qDebug("WLANModule found interface %s",interface.latin1()); |
162 | ifa = i; | 162 | ifa = i; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | if (ifa == 0){ | 166 | if (ifa == 0){ |
167 | qDebug("WLANModule Did not find %s",interface.latin1()); | 167 | qDebug("WLANModule Did not find %s",interface.latin1()); |
168 | qDebug("skipping"); | 168 | qDebug("skipping"); |
169 | count = 0; | 169 | count = 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | if (count == 2){ | 172 | if (count == 2){ |
173 | // those should call the interface directly | 173 | // those should call the interface directly |
174 | QWidget *info = getInfo( ifa ); | 174 | QWidget *info = getInfo( ifa ); |
175 | info->showMaximized(); | 175 | info->showMaximized(); |
176 | 176 | ||
177 | if ( action.contains("start" ) ){ | 177 | if ( action.contains("start" ) ){ |
178 | ifa->start(); | 178 | ifa->start(); |
179 | } else if ( action.contains("restart" ) ){ | 179 | } else if ( action.contains("restart" ) ){ |
180 | ifa->restart(); | 180 | ifa->restart(); |
181 | } else if ( action.contains("stop" ) ){ | 181 | } else if ( action.contains("stop" ) ){ |
182 | ifa->stop(); | 182 | ifa->stop(); |
183 | }else if ( action.contains("refresh" ) ){ | 183 | }else if ( action.contains("refresh" ) ){ |
184 | ifa->refresh(); | 184 | ifa->refresh(); |
185 | } | 185 | } |
186 | }else if (count == 3){ | 186 | }else if (count == 3){ |
187 | QString value; | 187 | QString value; |
188 | if (!wlanconfigWiget){ | 188 | if (!wlanconfigWiget){ |
189 | //FIXME: what if it got closed meanwhile? | 189 | //FIXME: what if it got closed meanwhile? |
190 | wlanconfigWiget = (WLANImp*) configure(ifa); | 190 | wlanconfigWiget = (WLANImp*) configure(ifa); |
191 | toShow = (QDialog*) wlanconfigWiget; | 191 | toShow = (QDialog*) wlanconfigWiget; |
192 | } | 192 | } |
193 | wlanconfigWiget->showMaximized(); | 193 | wlanconfigWiget->showMaximized(); |
194 | stream >> value; | 194 | stream >> value; |