summaryrefslogtreecommitdiff
authortille <tille>2003-06-16 16:56:06 (UTC)
committer tille <tille>2003-06-16 16:56:06 (UTC)
commitad64cf15ac6ac064619079592f7656464e88baac (patch) (unidiff)
tree54ed14a9cff9bdefcadb5ac5e04e5b3c104207ac
parentc6e6ec7a25dd0acfd970d0b9e2f43a8ea500b98b (diff)
downloadopie-ad64cf15ac6ac064619079592f7656464e88baac.zip
opie-ad64cf15ac6ac064619079592f7656464e88baac.tar.gz
opie-ad64cf15ac6ac064619079592f7656464e88baac.tar.bz2
add support for multiline qcop calls
and macaddrs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp7
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp120
2 files changed, 62 insertions, 65 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 5029525..544498f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -600,68 +600,61 @@ void MainWindowImp::removeProfile(){
600 * @param newProfile the new profile. 600 * @param newProfile the new profile.
601 */ 601 */
602void MainWindowImp::changeProfile(){ 602void MainWindowImp::changeProfile(){
603 if(profilesList->currentItem() == -1){ 603 if(profilesList->currentItem() == -1){
604 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 604 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
605 return; 605 return;
606 } 606 }
607 QString newProfile = profilesList->text(profilesList->currentItem()); 607 QString newProfile = profilesList->text(profilesList->currentItem());
608 if(newProfile != currentProfileLabel->text()){ 608 if(newProfile != currentProfileLabel->text()){
609 currentProfileLabel->setText(newProfile); 609 currentProfileLabel->setText(newProfile);
610 QFile::remove(scheme); 610 QFile::remove(scheme);
611 QFile file(scheme); 611 QFile file(scheme);
612 if ( file.open(IO_ReadWrite) ) { 612 if ( file.open(IO_ReadWrite) ) {
613 QTextStream stream( &file ); 613 QTextStream stream( &file );
614 stream << QString("SCHEME=%1").arg(newProfile); 614 stream << QString("SCHEME=%1").arg(newProfile);
615 file.close(); 615 file.close();
616 } 616 }
617 // restart all up devices? 617 // restart all up devices?
618 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 618 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
619 // Go through them one by one 619 // Go through them one by one
620 QMap<Interface*, QListViewItem*>::Iterator it; 620 QMap<Interface*, QListViewItem*>::Iterator it;
621 for( it = items.begin(); it != items.end(); ++it ){ 621 for( it = items.begin(); it != items.end(); ++it ){
622 if(it.key()->getStatus() == true) 622 if(it.key()->getStatus() == true)
623 it.key()->restart(); 623 it.key()->restart();
624 } 624 }
625 } 625 }
626 } 626 }
627 // TODO change the profile in the modules 627 // TODO change the profile in the modules
628} 628}
629 629
630 630
631void MainWindowImp::makeChannel() 631void MainWindowImp::makeChannel()
632{ 632{
633 channel = new QCopChannel( "QPE/Application/networksettings", this ); 633 channel = new QCopChannel( "QPE/Application/networksettings", this );
634 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 634 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
635 this, SLOT(receive(const QCString&, const QByteArray&)) ); 635 this, SLOT(receive(const QCString&, const QByteArray&)) );
636} 636}
637 637
638void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) 638void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
639{ 639{
640 bool found = false; 640 bool found = false;
641 qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); 641 qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
642 642
643 QString dest = msg.left(msg.find("(")); 643 QString dest = msg.left(msg.find("("));
644 QCString param = msg.right(msg.length() - msg.find("(") - 1); 644 QCString param = msg.right(msg.length() - msg.find("(") - 1);
645 param = param.left( param.length() - 1 ); 645 param = param.left( param.length() - 1 );
646 qDebug("dest >%s< param >"+param+"<",dest.latin1()); 646 qDebug("dest >%s< param >"+param+"<",dest.latin1());
647 647
648// if (param.contains("QString,QString,QString")) {
649// QDataStream stream(arg,IO_ReadOnly);
650// QString arg1, arg2, arg3;
651// stream >> arg1 >> arg2 >> arg3 ;
652// qDebug("args: >%s< >%s< >%s<",arg1.latin1(),arg2.latin1(),arg3.latin1());
653// }
654
655 QMap<Module*, QLibrary*>::Iterator it; 648 QMap<Module*, QLibrary*>::Iterator it;
656 for( it = libraries.begin(); it != libraries.end(); ++it ){ 649 for( it = libraries.begin(); it != libraries.end(); ++it ){
657 qDebug("plugin >%s<", it.key()->type().latin1() ); 650 qDebug("plugin >%s<", it.key()->type().latin1() );
658 if(it.key()->type() == dest){ 651 if(it.key()->type() == dest){
659 it.key()->receive( param, arg ); 652 it.key()->receive( param, arg );
660 found = true; 653 found = true;
661 } 654 }
662 } 655 }
663 656
664 657
665 if (found) QPEApplication::setKeepRunning(); 658 if (found) QPEApplication::setKeepRunning();
666 else qDebug("Huh what do ya want"); 659 else qDebug("Huh what do ya want");
667} 660}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index bc467bb..e34f0ce 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,57 +1,58 @@
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 <qprogressbar.h> 11#include <qprogressbar.h>
11#include <qspinbox.h> 12#include <qspinbox.h>
12#include <qtabwidget.h> 13#include <qtabwidget.h>
13 14
14 15
15 16
16 17
17/** 18/**
18 * Constructor, find all of the possible interfaces 19 * Constructor, find all of the possible interfaces
19 */ 20 */
20WLANModule::WLANModule() 21WLANModule::WLANModule()
21 : Module(), 22 : Module(),
22 wlanconfigWiget(0) 23 wlanconfigWiget(0)
23{ 24{
24} 25}
25 26
26/** 27/**
27 * Delete any interfaces that we own. 28 * Delete any interfaces that we own.
28 */ 29 */
29WLANModule::~WLANModule(){ 30WLANModule::~WLANModule(){
30 Interface *i; 31 Interface *i;
31 for ( i=list.first(); i != 0; i=list.next() ) 32 for ( i=list.first(); i != 0; i=list.next() )
32 delete i; 33 delete i;
33 34
34} 35}
35 36
36/** 37/**
37 * Change the current profile 38 * Change the current profile
38 */ 39 */
39void WLANModule::setProfile(const QString &newProfile){ 40void WLANModule::setProfile(const QString &newProfile){
40 profile = newProfile; 41 profile = newProfile;
41} 42}
42 43
43/** 44/**
44 * get the icon name for this device. 45 * get the icon name for this device.
45 * @param Interface* can be used in determining the icon. 46 * @param Interface* can be used in determining the icon.
46 * @return QString the icon name (minus .png, .gif etc) 47 * @return QString the icon name (minus .png, .gif etc)
47 */ 48 */
48QString WLANModule::getPixmapName(Interface* ){ 49QString WLANModule::getPixmapName(Interface* ){
49 return "wlan"; 50 return "wlan";
50} 51}
51 52
52/** 53/**
53 * 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.
54 * @param Interface* interface to check against 55 * @param Interface* interface to check against
55 * @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.
56 */ 57 */
57bool WLANModule::isOwner(Interface *i){ 58bool WLANModule::isOwner(Interface *i){
@@ -86,124 +87,127 @@ QWidget *WLANModule::information(Interface *i){
86 return getInfo( i ); 87 return getInfo( i );
87} 88}
88 89
89/** 90/**
90 * Get all active (up or down) interfaces 91 * Get all active (up or down) interfaces
91 * @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
92 * been called by isOwner() 93 * been called by isOwner()
93 */ 94 */
94QList<Interface> WLANModule::getInterfaces(){ 95QList<Interface> WLANModule::getInterfaces(){
95 return list; 96 return list;
96} 97}
97 98
98/** 99/**
99 * Attempt to add a new interface as defined by name 100 * Attempt to add a new interface as defined by name
100 * @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
101 * by possibleNewInterfaces(); 102 * by possibleNewInterfaces();
102 * @return Interface* NULL if it was unable to be created. 103 * @return Interface* NULL if it was unable to be created.
103 */ 104 */
104Interface *WLANModule::addNewInterface(const QString &){ 105Interface *WLANModule::addNewInterface(const QString &){
105 // 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
106 // or it wont. 107 // or it wont.
107 return NULL; 108 return NULL;
108} 109}
109 110
110/** 111/**
111 * Attempts to remove the interface, doesn't delete i 112 * Attempts to remove the interface, doesn't delete i
112 * @return bool true if successfull, false otherwise. 113 * @return bool true if successfull, false otherwise.
113 */ 114 */
114bool WLANModule::remove(Interface*){ 115bool WLANModule::remove(Interface*){
115 // Can't remove a hardware device, you can stop it though. 116 // Can't remove a hardware device, you can stop it though.
116 return false; 117 return false;
117} 118}
118 119
119void WLANModule::receive(const QCString &param, const QByteArray &arg) 120void WLANModule::receive(const QCString &param, const QByteArray &arg)
120{ 121{
121 qDebug("WLANModule::receive "+param); 122 qDebug("WLANModule::receive "+param);
122 QStringList params = QStringList::split(",",param); 123 QStringList params = QStringList::split(",",param);
123 int count = params.count(); 124 int count = params.count();
124 qDebug("WLANModule got %i params", count ); 125 qDebug("WLANModule got %i params", count );
125 if (count < 2){ 126 if (count < 2){
126 qDebug("Erorr less than 2 parameter"); 127 qDebug("Erorr less than 2 parameter");
127 qDebug("RETURNING"); 128 qDebug("RETURNING");
128 return; 129 return;
129 } 130 }
130 131
131 QDataStream stream(arg,IO_ReadOnly); 132 QDataStream stream(arg,IO_ReadOnly);
132 QString interface; 133 QString interface;
133 QString action; 134 QString action;
134 135 while (! stream.atEnd() ){
135 stream >> interface; 136 stream >> interface;
136 stream >> action; 137 stream >> action;
137 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());
138 // find interfaces 139 // find interfaces
139 Interface *ifa=0; 140 Interface *ifa=0;
140 for ( Interface *i=list.first(); i != 0; i=list.next() ){ 141 for ( Interface *i=list.first(); i != 0; i=list.next() ){
141 if (i->getInterfaceName() == interface){ 142 if (i->getInterfaceName() == interface){
142 qDebug("WLANModule found interface %s",interface.latin1()); 143 qDebug("WLANModule found interface %s",interface.latin1());
143 ifa = i; 144 ifa = i;
145 }
144 } 146 }
145 }
146
147 if (ifa == 0){
148 qFatal("WLANModule Did not find %s",interface.latin1());
149 }
150 147
151 if (count == 2){ 148 if (ifa == 0){
152 // those should call the interface directly 149 qFatal("WLANModule Did not find %s",interface.latin1());
153 QWidget *info = getInfo( ifa );
154 info->showMaximized();
155
156 if ( action.contains("start" ) ){
157 ifa->start();
158 } else if ( action.contains("restart" ) ){
159 ifa->restart();
160 } else if ( action.contains("stop" ) ){
161 ifa->stop();
162 }else if ( action.contains("refresh" ) ){
163 ifa->refresh();
164 }
165 }else if (count == 3){
166 QString value;
167 if (!wlanconfigWiget){
168 //FIXME: what if it got closed meanwhile?
169 wlanconfigWiget = (WLANImp*) configure(ifa);
170 } 150 }
171 wlanconfigWiget->showMaximized(); 151
172 stream >> value; 152 if (count == 2){
173 qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); 153 // those should call the interface directly
174 if ( action.contains("ESSID") ){ 154 QWidget *info = getInfo( ifa );
175 QComboBox *combo = wlanconfigWiget->essid; 155 info->showMaximized();
176 bool found = false; 156
177 for ( int i = 0; i < combo->count(); i++) 157 if ( action.contains("start" ) ){
178 if ( combo->text( i ) == value ){ 158 ifa->start();
179 combo->setCurrentItem( i ); 159 } else if ( action.contains("restart" ) ){
180 found = true; 160 ifa->restart();
161 } else if ( action.contains("stop" ) ){
162 ifa->stop();
163 }else if ( action.contains("refresh" ) ){
164 ifa->refresh();
165 }
166 }else if (count == 3){
167 QString value;
168 if (!wlanconfigWiget){
169 //FIXME: what if it got closed meanwhile?
170 wlanconfigWiget = (WLANImp*) configure(ifa);
171 }
172 wlanconfigWiget->showMaximized();
173 stream >> value;
174 qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
175 if ( action.contains("ESSID") ){
176 QComboBox *combo = wlanconfigWiget->essid;
177 bool found = false;
178 for ( int i = 0; i < combo->count(); i++)
179 if ( combo->text( i ) == value ){
180 combo->setCurrentItem( i );
181 found = true;
181 } 182 }
182 if (!found) combo->insertItem( value, 0 ); 183 if (!found) combo->insertItem( value, 0 );
183 }else if ( action.contains("Mode") ){ 184 }else if ( action.contains("Mode") ){
184 QComboBox *combo = wlanconfigWiget->mode; 185 QComboBox *combo = wlanconfigWiget->mode;
185 for ( int i = 0; i < combo->count(); i++) 186 for ( int i = 0; i < combo->count(); i++)
186 if ( combo->text( i ) == value ){ 187 if ( combo->text( i ) == value ){
187 combo->setCurrentItem( i ); 188 combo->setCurrentItem( i );
188 } 189 }
189 190
190 }else if (action.contains("Channel")){ 191 }else if (action.contains("Channel")){
191 wlanconfigWiget->specifyChan->setChecked( true ); 192 wlanconfigWiget->specifyChan->setChecked( true );
192 wlanconfigWiget->networkChannel->setValue( value.toInt() ); 193 wlanconfigWiget->networkChannel->setValue( value.toInt() );
193 }else 194 }else if (action.contains("MacAddr")){
194 qDebug("wlan plugin has no clue"); 195 wlanconfigWiget->specifyAp->setChecked( true );
195 } 196 wlanconfigWiget->macEdit->setText( value );
196 197 }else
198 qDebug("wlan plugin has no clue");
199 }
200 }// while stream
197} 201}
198 202
199QWidget *WLANModule::getInfo( Interface *i) 203QWidget *WLANModule::getInfo( Interface *i)
200{ 204{
201 qDebug("WLANModule::getInfo start"); 205 qDebug("WLANModule::getInfo start");
202 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); 206 WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
203 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); 207 InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
204 info->tabWidget->insertTab(information, "TCP/IP", 0); 208 info->tabWidget->insertTab(information, "TCP/IP", 0);
205 209
206 qDebug("WLANModule::getInfo return"); 210 qDebug("WLANModule::getInfo return");
207 return info; 211 return info;
208} 212}
209 213