summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-16 20:21:06 (UTC)
committer harlekin <harlekin>2002-06-16 20:21:06 (UTC)
commit5c098847f0fd716c4fe697e5eb314111a4ae5df1 (patch) (unidiff)
tree590ed709442bf6ba4a28eb242840dcf1de6da756
parent8dde6abcd14717bd362248c365fe140efe0f0386 (diff)
downloadopie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.zip
opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.gz
opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.bz2
remoteDevice not removeDevices
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc12
-rw-r--r--noncore/net/opietooth/lib/manager.h6
-rw-r--r--noncore/net/opietooth/lib/remotedevice.cc22
-rw-r--r--noncore/net/opietooth/lib/remotedevice.h16
-rw-r--r--noncore/net/opietooth/manager/bluebase.h2
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp3
-rw-r--r--noncore/net/opietooth/manager/scandialog.h4
7 files changed, 33 insertions, 32 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 40c1f0a..c454588 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1,213 +1,213 @@
1#include <opie/oprocess.h> 1#include <opie/oprocess.h>
2 2
3#include "manager.h" 3#include "manager.h"
4 4
5 5
6using namespace OpieTooth; 6using namespace OpieTooth;
7 7
8Manager::Manager( const QString& dev ) 8Manager::Manager( const QString& dev )
9 : QObject() 9 : QObject()
10{ 10{
11 qWarning("created"); 11 qWarning("created");
12 m_device = dev; 12 m_device = dev;
13 m_hcitool = 0; 13 m_hcitool = 0;
14 m_sdp = 0; 14 m_sdp = 0;
15} 15}
16Manager::Manager( Device* dev ) 16Manager::Manager( Device* dev )
17 : QObject() 17 : QObject()
18{ 18{
19 m_hcitool = 0; 19 m_hcitool = 0;
20 m_sdp = 0; 20 m_sdp = 0;
21} 21}
22Manager::Manager() 22Manager::Manager()
23 : QObject() 23 : QObject()
24{ 24{
25 m_hcitool = 0; 25 m_hcitool = 0;
26 m_sdp = 0; 26 m_sdp = 0;
27} 27}
28Manager::~Manager(){ 28Manager::~Manager(){
29 delete m_hcitool; 29 delete m_hcitool;
30 delete m_sdp; 30 delete m_sdp;
31} 31}
32void Manager::setDevice( const QString& dev ){ 32void Manager::setDevice( const QString& dev ){
33 m_device = dev; 33 m_device = dev;
34} 34}
35void Manager::setDevice( Device* dev ){ 35void Manager::setDevice( Device* dev ){
36 36
37} 37}
38void Manager::isConnected( const QString& device ){ 38void Manager::isConnected( const QString& device ){
39 OProcess* l2ping = new OProcess(); 39 OProcess* l2ping = new OProcess();
40 l2ping->setName( device.latin1() ); 40 l2ping->setName( device.latin1() );
41 *l2ping << "l2ping" << "-c1" << device; 41 *l2ping << "l2ping" << "-c1" << device;
42 connect(l2ping, SIGNAL(processExited(OProcess* ) ), 42 connect(l2ping, SIGNAL(processExited(OProcess* ) ),
43 this, SLOT(slotProcessExited(OProcess*) ) ); 43 this, SLOT(slotProcessExited(OProcess*) ) );
44 if (!l2ping->start() ) { 44 if (!l2ping->start() ) {
45 emit connected( device, false ); 45 emit connected( device, false );
46 delete l2ping; 46 delete l2ping;
47 } 47 }
48 48
49} 49}
50void Manager::isConnected( Device* dev ){ 50void Manager::isConnected( Device* dev ){
51 51
52 52
53} 53}
54void Manager::searchDevices( const QString& device ){ 54void Manager::searchDevices( const QString& device ){
55 qWarning("search devices"); 55 qWarning("search devices");
56 OProcess* hcitool = new OProcess(); 56 OProcess* hcitool = new OProcess();
57 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 57 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
58 *hcitool << "hcitool" << "scan"; 58 *hcitool << "hcitool" << "scan";
59 connect( hcitool, SIGNAL(processExited(OProcess*) ) , 59 connect( hcitool, SIGNAL(processExited(OProcess*) ) ,
60 this, SLOT(slotHCIExited(OProcess* ) ) ); 60 this, SLOT(slotHCIExited(OProcess* ) ) );
61 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 61 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
62 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 62 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
63 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 63 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
64 qWarning("could not start"); 64 qWarning("could not start");
65 RemoteDevices::ValueList list; 65 RemoteDevice::ValueList list;
66 emit foundDevices( device, list ); 66 emit foundDevices( device, list );
67 delete hcitool; 67 delete hcitool;
68 } 68 }
69} 69}
70 70
71void Manager::searchDevices(Device* d ){ 71void Manager::searchDevices(Device* d ){
72 72
73 73
74} 74}
75void Manager::addService(const QString& name ){ 75void Manager::addService(const QString& name ){
76 OProcess proc; 76 OProcess proc;
77 proc << "sdptool" << "add" << name; 77 proc << "sdptool" << "add" << name;
78 bool bo = true; 78 bool bo = true;
79 if (!proc.start(OProcess::DontCare ) ) 79 if (!proc.start(OProcess::DontCare ) )
80 bo = false; 80 bo = false;
81 emit addedService( name, bo ); 81 emit addedService( name, bo );
82} 82}
83void Manager::addServices(const QStringList& list){ 83void Manager::addServices(const QStringList& list){
84 QStringList::ConstIterator it; 84 QStringList::ConstIterator it;
85 for (it = list.begin(); it != list.end(); ++it ) 85 for (it = list.begin(); it != list.end(); ++it )
86 addService( (*it) ); 86 addService( (*it) );
87} 87}
88void Manager::removeService( const QString& name ){ 88void Manager::removeService( const QString& name ){
89 OProcess prc; 89 OProcess prc;
90 prc << "sdptool" << "del" << name; 90 prc << "sdptool" << "del" << name;
91 bool bo = true; 91 bool bo = true;
92 if (!prc.start(OProcess::DontCare ) ) 92 if (!prc.start(OProcess::DontCare ) )
93 bo = false; 93 bo = false;
94 emit removedService( name, bo ); 94 emit removedService( name, bo );
95} 95}
96void Manager::removeServices( const QStringList& list){ 96void Manager::removeServices( const QStringList& list){
97 QStringList::ConstIterator it; 97 QStringList::ConstIterator it;
98 for (it = list.begin(); it != list.end(); ++it ) 98 for (it = list.begin(); it != list.end(); ++it )
99 removeService( (*it) ); 99 removeService( (*it) );
100} 100}
101void Manager::searchServices( const QString& remDevice ){ 101void Manager::searchServices( const QString& remDevice ){
102 OProcess *m_sdp =new OProcess(); 102 OProcess *m_sdp =new OProcess();
103 *m_sdp << "sdptool" << "browse" << remDevice; 103 *m_sdp << "sdptool" << "browse" << remDevice;
104 m_sdp->setName( remDevice.latin1() ); 104 m_sdp->setName( remDevice.latin1() );
105 connect(m_sdp, SIGNAL(processExited(OProcess*) ), 105 connect(m_sdp, SIGNAL(processExited(OProcess*) ),
106 this, SLOT(slotSDPExited(OProcess* ) ) ); 106 this, SLOT(slotSDPExited(OProcess* ) ) );
107 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 107 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
108 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 108 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
109 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 109 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
110 delete m_sdp; 110 delete m_sdp;
111 Services::ValueList list; 111 Services::ValueList list;
112 emit foundServices( remDevice, list ); 112 emit foundServices( remDevice, list );
113 } 113 }
114} 114}
115void Manager::searchServices( const RemoteDevices& dev){ 115void Manager::searchServices( const RemoteDevice& dev){
116 searchServices( dev.mac() ); 116 searchServices( dev.mac() );
117} 117}
118QString Manager::toDevice( const QString& mac ){ 118QString Manager::toDevice( const QString& mac ){
119 119
120} 120}
121QString Manager::toMac( const QString &device ){ 121QString Manager::toMac( const QString &device ){
122 122
123} 123}
124void Manager::slotProcessExited(OProcess* proc ) { 124void Manager::slotProcessExited(OProcess* proc ) {
125 bool conn= false; 125 bool conn= false;
126 if (proc->normalExit() && proc->exitStatus() == 0 ) 126 if (proc->normalExit() && proc->exitStatus() == 0 )
127 conn = true; 127 conn = true;
128 128
129 QString name = QString::fromLatin1(proc->name() ); 129 QString name = QString::fromLatin1(proc->name() );
130 emit connected( name, conn ); 130 emit connected( name, conn );
131 delete proc; 131 delete proc;
132} 132}
133void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 133void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
134{ 134{
135 QCString str(ch, len+1 ); 135 QCString str(ch, len+1 );
136 QMap<QString, QString>::Iterator it; 136 QMap<QString, QString>::Iterator it;
137 it = m_out.find(proc->name() ); 137 it = m_out.find(proc->name() );
138 if ( it != m_out.end() ) { 138 if ( it != m_out.end() ) {
139 QString string = it.data(); 139 QString string = it.data();
140 string.append( str ); 140 string.append( str );
141 m_out.replace( proc->name(), string ); 141 m_out.replace( proc->name(), string );
142 } 142 }
143 143
144} 144}
145void Manager::slotSDPExited( OProcess* proc) 145void Manager::slotSDPExited( OProcess* proc)
146{ 146{
147 Services::ValueList list; 147 Services::ValueList list;
148 if (proc->normalExit() ) { 148 if (proc->normalExit() ) {
149 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 149 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
150 if ( it != m_out.end() ) { 150 if ( it != m_out.end() ) {
151 list = parseSDPOutput( it.data() ); 151 list = parseSDPOutput( it.data() );
152 m_out.remove( it ); 152 m_out.remove( it );
153 } 153 }
154 } 154 }
155 emit foundServices( proc->name(), list ); 155 emit foundServices( proc->name(), list );
156 delete proc; 156 delete proc;
157} 157}
158Services::ValueList Manager::parseSDPOutput( const QString& out ) { 158Services::ValueList Manager::parseSDPOutput( const QString& out ) {
159 Services::ValueList list; 159 Services::ValueList list;
160 return list; 160 return list;
161} 161}
162 162
163void Manager::slotHCIExited(OProcess* proc ) { 163void Manager::slotHCIExited(OProcess* proc ) {
164 qWarning("process exited"); 164 qWarning("process exited");
165 RemoteDevices::ValueList list; 165 RemoteDevice::ValueList list;
166 if (proc->normalExit() ) { 166 if (proc->normalExit() ) {
167 qWarning("normalExit %s", proc->name() ); 167 qWarning("normalExit %s", proc->name() );
168 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 168 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
169 if (it != m_devices.end() ) { 169 if (it != m_devices.end() ) {
170 qWarning("!= end ;)"); 170 qWarning("!= end ;)");
171 list = parseHCIOutput( it.data() ); 171 list = parseHCIOutput( it.data() );
172 m_devices.remove( it ); 172 m_devices.remove( it );
173 } 173 }
174 } 174 }
175 emit foundDevices( proc->name(), list ); 175 emit foundDevices( proc->name(), list );
176 delete proc; 176 delete proc;
177} 177}
178void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 178void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
179 QCString str( ch, len+1 ); 179 QCString str( ch, len+1 );
180 qWarning("hci: %s", str.data() ); 180 qWarning("hci: %s", str.data() );
181 QMap<QString, QString>::Iterator it; 181 QMap<QString, QString>::Iterator it;
182 it = m_devices.find( proc->name() ); 182 it = m_devices.find( proc->name() );
183 qWarning("proc->name %s", proc->name() ); 183 qWarning("proc->name %s", proc->name() );
184 QString string; 184 QString string;
185 if (it != m_devices.end() ) { 185 if (it != m_devices.end() ) {
186 qWarning("slotHCIOut "); 186 qWarning("slotHCIOut ");
187 string = it.data(); 187 string = it.data();
188 } 188 }
189 string.append( str ); 189 string.append( str );
190 190
191 m_devices.replace( proc->name(), string ); 191 m_devices.replace( proc->name(), string );
192} 192}
193RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) { 193RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
194 qWarning("parseHCI %s", output.latin1() ); 194 qWarning("parseHCI %s", output.latin1() );
195 RemoteDevices::ValueList list; 195 RemoteDevice::ValueList list;
196 QStringList strList = QStringList::split('\n', output ); 196 QStringList strList = QStringList::split('\n', output );
197 QStringList::Iterator it; 197 QStringList::Iterator it;
198 QString str; 198 QString str;
199 for ( it = strList.begin(); it != strList.end(); ++it ) { 199 for ( it = strList.begin(); it != strList.end(); ++it ) {
200 str = (*it).stripWhiteSpace(); 200 str = (*it).stripWhiteSpace();
201 qWarning("OpieTooth %s", str.latin1() ); 201 qWarning("OpieTooth %s", str.latin1() );
202 int pos = str.findRev(':' ); 202 int pos = str.findRev(':' );
203 if ( pos > 0 ) { 203 if ( pos > 0 ) {
204 QString mac = str.left(17 ); 204 QString mac = str.left(17 );
205 str.remove( 0, 17 ); 205 str.remove( 0, 17 );
206 qWarning("mac %s", mac.latin1() ); 206 qWarning("mac %s", mac.latin1() );
207 qWarning("rest:%s", str.latin1() ); 207 qWarning("rest:%s", str.latin1() );
208 RemoteDevices rem( mac , str.stripWhiteSpace() ); 208 RemoteDevice rem( mac , str.stripWhiteSpace() );
209 list.append( rem ); 209 list.append( rem );
210 } 210 }
211 } 211 }
212 return list; 212 return list;
213} 213}
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h
index 95e4306..aba70f7 100644
--- a/noncore/net/opietooth/lib/manager.h
+++ b/noncore/net/opietooth/lib/manager.h
@@ -5,127 +5,127 @@
5#include <qobject.h> 5#include <qobject.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qmap.h> 7#include <qmap.h>
8#include <qvaluelist.h> 8#include <qvaluelist.h>
9 9
10#include "remotedevice.h" 10#include "remotedevice.h"
11#include "services.h" 11#include "services.h"
12 12
13class OProcess; 13class OProcess;
14namespace OpieTooth { 14namespace OpieTooth {
15 class Device; 15 class Device;
16 /** Manager manages a blueZ device (hci0 for example) 16 /** Manager manages a blueZ device (hci0 for example)
17 * with Manager you can control the things you 17 * with Manager you can control the things you
18 * could do from command line in a OO and asynchronus 18 * could do from command line in a OO and asynchronus
19 * way. 19 * way.
20 */ 20 */
21 class Manager : public QObject { 21 class Manager : public QObject {
22Q_OBJECT 22Q_OBJECT
23 public: 23 public:
24 /** c'tor whichs create a new Manager 24 /** c'tor whichs create a new Manager
25 * @param device is the device to use. Either a mac or blueZ device name 25 * @param device is the device to use. Either a mac or blueZ device name
26 * 26 *
27 */ 27 */
28 Manager( const QString &device ); 28 Manager( const QString &device );
29 /** c'tor 29 /** c'tor
30 * @param dev The Device to be managed 30 * @param dev The Device to be managed
31 * We don't care of Device so you need to delete it 31 * We don't care of Device so you need to delete it
32 */ 32 */
33 Manager( Device* dev ); 33 Manager( Device* dev );
34 /** 34 /**
35 * c'tor 35 * c'tor
36 */ 36 */
37 Manager(); 37 Manager();
38 ~Manager(); 38 ~Manager();
39 39
40 /** Set the manager to control a new device 40 /** Set the manager to control a new device
41 * @param device the new device to control (hci0 ) 41 * @param device the new device to control (hci0 )
42 */ 42 */
43 void setDevice( const QString& device ); 43 void setDevice( const QString& device );
44 /** 44 /**
45 * Convience functions for setting a new device 45 * Convience functions for setting a new device
46 */ 46 */
47 void setDevice( Device *dev ); 47 void setDevice( Device *dev );
48 /** 48 /**
49 * Wether or not a device is connected. The function 49 * Wether or not a device is connected. The function
50 * is asynchron 50 * is asynchron
51 * If device is empty it will take the currently managed 51 * If device is empty it will take the currently managed
52 * device and see if it's up 52 * device and see if it's up
53 * for Remote devices it will ping and see. 53 * for Remote devices it will ping and see.
54 * @param either mac or hciX 54 * @param either mac or hciX
55 */ 55 */
56 void isConnected(const QString& device= QString::null ); 56 void isConnected(const QString& device= QString::null );
57 /** 57 /**
58 * same as above 58 * same as above
59 */ 59 */
60 void isConnected(Device *dev ); 60 void isConnected(Device *dev );
61 61
62 /** this searchs for devices reachable from the 62 /** this searchs for devices reachable from the
63 * currently managed device 63 * currently managed device
64 * or from device if @param device is not empty 64 * or from device if @param device is not empty
65 */ 65 */
66 void searchDevices(const QString& device= QString::null ); 66 void searchDevices(const QString& device= QString::null );
67 /** same as above 67 /** same as above
68 * 68 *
69 */ 69 */
70 void searchDevices(Device *d ); 70 void searchDevices(Device *d );
71 71
72 /** 72 /**
73 * This will add the service @param name 73 * This will add the service @param name
74 * to the sdpd daemon 74 * to the sdpd daemon
75 * It will start the daemon if necessary 75 * It will start the daemon if necessary
76 */ 76 */
77 void addService(const QString &name ); 77 void addService(const QString &name );
78 /** 78 /**
79 * This will add the services @param names 79 * This will add the services @param names
80 * to the sdpd daemon 80 * to the sdpd daemon
81 * It will start the daemon if necessary 81 * It will start the daemon if necessary
82 */ 82 */
83 void addServices( const QStringList& names ); 83 void addServices( const QStringList& names );
84 /** 84 /**
85 * This removes a service from the sdps 85 * This removes a service from the sdps
86 */ 86 */
87 void removeService(const QString &name ); 87 void removeService(const QString &name );
88 /** 88 /**
89 * Removes a list from the sdpd 89 * Removes a list from the sdpd
90 */ 90 */
91 void removeServices(const QStringList& ); 91 void removeServices(const QStringList& );
92 92
93 /** 93 /**
94 * search for services on a remote device 94 * search for services on a remote device
95 * 95 *
96 */ 96 */
97 void searchServices( const QString& remDevice ); 97 void searchServices( const QString& remDevice );
98 /** 98 /**
99 * search for services on a remote device 99 * search for services on a remote device
100 */ 100 */
101 void searchServices( const RemoteDevices& ); 101 void searchServices( const RemoteDevice& );
102 /*static*/ QString toDevice( const QString& mac ); 102 /*static*/ QString toDevice( const QString& mac );
103 /*static*/ QString toMac( const QString &device ); 103 /*static*/ QString toMac( const QString &device );
104 104
105 signals: 105 signals:
106 // device either mac or dev name 106 // device either mac or dev name
107 // the first device is the device which you access 107 // the first device is the device which you access
108 void connected( const QString& device, bool connected ); 108 void connected( const QString& device, bool connected );
109 void addedService( const QString& service, bool added ); 109 void addedService( const QString& service, bool added );
110 void removedService( const QString& service, bool removed ); 110 void removedService( const QString& service, bool removed );
111 void foundServices( const QString& device, Services::ValueList ); 111 void foundServices( const QString& device, Services::ValueList );
112 void foundDevices( const QString& device, RemoteDevices::ValueList ); 112 void foundDevices( const QString& device, RemoteDevice::ValueList );
113 113
114private slots: 114private slots:
115 void slotProcessExited(OProcess* ); 115 void slotProcessExited(OProcess* );
116 void slotSDPExited(OProcess*); 116 void slotSDPExited(OProcess*);
117 void slotSDPOut(OProcess*, char*, int); 117 void slotSDPOut(OProcess*, char*, int);
118 void slotHCIExited(OProcess* ); 118 void slotHCIExited(OProcess* );
119 void slotHCIOut(OProcess*, char*, int ); 119 void slotHCIOut(OProcess*, char*, int );
120 private: 120 private:
121 Services::ValueList parseSDPOutput( const QString& ); 121 Services::ValueList parseSDPOutput( const QString& );
122 RemoteDevices::ValueList parseHCIOutput( const QString& ); 122 RemoteDevice::ValueList parseHCIOutput( const QString& );
123 OProcess *m_hcitool; 123 OProcess *m_hcitool;
124 OProcess *m_sdp; // not only one 124 OProcess *m_sdp; // not only one
125 QString m_device; 125 QString m_device;
126 QMap<QString, QString> m_out; 126 QMap<QString, QString> m_out;
127 QMap<QString, QString> m_devices; 127 QMap<QString, QString> m_devices;
128 }; 128 };
129}; 129};
130 130
131#endif 131#endif
diff --git a/noncore/net/opietooth/lib/remotedevice.cc b/noncore/net/opietooth/lib/remotedevice.cc
index 0045904..08fb397 100644
--- a/noncore/net/opietooth/lib/remotedevice.cc
+++ b/noncore/net/opietooth/lib/remotedevice.cc
@@ -1,48 +1,48 @@
1 1
2#include "remotedevice.h" 2#include "remotedevice.h"
3 3
4using namespace OpieTooth; 4using namespace OpieTooth;
5 5
6bool operator==(const RemoteDevices& rem1, const RemoteDevices& rem2){ 6bool operator==(const RemoteDevice& rem1, const RemoteDevice& rem2){
7 if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) ) 7 if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) )
8 return true; 8 return true;
9 9
10 return false; 10 return false;
11} 11}
12 12
13RemoteDevices::RemoteDevices(){ 13RemoteDevice::RemoteDevice(){
14 14
15} 15}
16RemoteDevices::RemoteDevices(const RemoteDevices& ole ){ 16RemoteDevice::RemoteDevice(const RemoteDevice& ole ){
17 (*this) = ole; 17 (*this) = ole;
18} 18}
19RemoteDevices::RemoteDevices(const QString &mac, const QString& name ){ 19RemoteDevice::RemoteDevice(const QString &mac, const QString& name ){
20 m_mac = mac; 20 m_mac = mac;
21 m_name = name; 21 m_name = name;
22} 22}
23RemoteDevices::~RemoteDevices(){ 23RemoteDevice::~RemoteDevice(){
24 24
25} 25}
26bool RemoteDevices::isEmpty() const { 26bool RemoteDevice::isEmpty() const {
27 if( m_name.isEmpty() && m_mac.isEmpty() ) 27 if( m_name.isEmpty() && m_mac.isEmpty() )
28 return true; 28 return true;
29 return false; 29 return false;
30}; 30};
31RemoteDevices& RemoteDevices::operator=( const RemoteDevices& rem1){ 31RemoteDevice& RemoteDevice::operator=( const RemoteDevice& rem1){
32 m_name = rem1.m_name; 32 m_name = rem1.m_name;
33 m_mac = rem1.m_mac; 33 m_mac = rem1.m_mac;
34 return *this; 34 return *this;
35 35
36} 36}
37QString RemoteDevices::mac() const { 37QString RemoteDevice::mac() const {
38 return m_mac; 38 return m_mac;
39} 39}
40void RemoteDevices::setMac( const QString& mac ){ 40void RemoteDevice::setMac( const QString& mac ){
41 m_mac = mac; 41 m_mac = mac;
42} 42}
43QString RemoteDevices::name() const{ 43QString RemoteDevice::name() const{
44 return m_name; 44 return m_name;
45} 45}
46void RemoteDevices::setName( const QString& name ){ 46void RemoteDevice::setName( const QString& name ){
47 m_name = name; 47 m_name = name;
48} 48}
diff --git a/noncore/net/opietooth/lib/remotedevice.h b/noncore/net/opietooth/lib/remotedevice.h
index 96a27de..23f98bd 100644
--- a/noncore/net/opietooth/lib/remotedevice.h
+++ b/noncore/net/opietooth/lib/remotedevice.h
@@ -1,28 +1,28 @@
1 1
2#ifndef OpieToothRemoteDevice 2#ifndef OpieToothRemoteDevice
3#define OpieToothRemoteDevice 3#define OpieToothRemoteDevice
4 4
5#include <qvaluelist.h> 5#include <qvaluelist.h>
6 6
7namespace OpieTooth{ 7namespace OpieTooth{
8 class RemoteDevices { 8 class RemoteDevice {
9 public: 9 public:
10 typedef QValueList<RemoteDevices> ValueList; 10 typedef QValueList<RemoteDevice> ValueList;
11 RemoteDevices(); 11 RemoteDevice();
12 RemoteDevices(const RemoteDevices& ); 12 RemoteDevice(const RemoteDevice& );
13 RemoteDevices(const QString &mac, const QString &name ); 13 RemoteDevice(const QString &mac, const QString &name );
14 ~RemoteDevices(); 14 ~RemoteDevice();
15 friend bool operator==(const RemoteDevices&, const RemoteDevices&); 15 friend bool operator==(const RemoteDevice&, const RemoteDevice&);
16 RemoteDevices &operator=(const RemoteDevices& ); 16 RemoteDevice &operator=(const RemoteDevice& );
17 bool isEmpty()const; 17 bool isEmpty()const;
18 QString mac()const; 18 QString mac()const;
19 void setMac(const QString& mac ); 19 void setMac(const QString& mac );
20 QString name()const; 20 QString name()const;
21 void setName( const QString& name ); 21 void setName( const QString& name );
22 private: 22 private:
23 QString m_name; 23 QString m_name;
24 QString m_mac; 24 QString m_mac;
25 }; 25 };
26}; 26};
27 27
28#endif 28#endif
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index ae5ce67..5364e51 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -1,61 +1,63 @@
1 1
2#ifndef BLUEBASE_H 2#ifndef BLUEBASE_H
3#define BLUEBASE_H 3#define BLUEBASE_H
4 4
5#include <qvariant.h> 5#include <qvariant.h>
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qscrollview.h> 7#include <qscrollview.h>
8#include <qsplitter.h> 8#include <qsplitter.h>
9#include <qlist.h> 9#include <qlist.h>
10 10
11#include "bluetoothbase.h" 11#include "bluetoothbase.h"
12 12
13#include <remotedevice.h>
14
13class QVBox; 15class QVBox;
14class QHBoxLayout; 16class QHBoxLayout;
15class QGridLayout; 17class QGridLayout;
16class QFrame; 18class QFrame;
17class QLabel; 19class QLabel;
18class QPushButton; 20class QPushButton;
19class QTabWidget; 21class QTabWidget;
20class QCheckBox; 22class QCheckBox;
21 23
22namespace OpieTooth { 24namespace OpieTooth {
23 25
24 26
25 27
26 class BlueBase : public BluetoothBase { 28 class BlueBase : public BluetoothBase {
27 Q_OBJECT 29 Q_OBJECT
28 30
29 public: 31 public:
30 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 32 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
31 ~BlueBase(); 33 ~BlueBase();
32 34
33 protected: 35 protected:
34 36
35 37
36 private slots: 38 private slots:
37 void startScan(); 39 void startScan();
38 40
39 private: 41 private:
40 void readConfig(); 42 void readConfig();
41 void writeConfig(); 43 void writeConfig();
42 QString getStatus(); 44 QString getStatus();
43 void initGui(); 45 void initGui();
44 46
45 47
46 QString deviceName; 48 QString deviceName;
47 QString defaultPasskey; 49 QString defaultPasskey;
48 int useEncryption; 50 int useEncryption;
49 int enableAuthentification; 51 int enableAuthentification;
50 int enablePagescan; 52 int enablePagescan;
51 int enableInquiryscan; 53 int enableInquiryscan;
52 54
53 private slots: 55 private slots:
54 void addSearchedDevices( QList<RemoteDevices> &newDevices ); 56 void addSearchedDevices( QList<RemoteDevices> &newDevices );
55 void applyConfigChanges(); 57 void applyConfigChanges();
56 58
57 }; 59 };
58 60
59} 61}
60 62
61#endif 63#endif
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 70ea77a..8a7ea01 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -41,130 +41,129 @@ namespace OpieTooth {
41 41
42/* 42/*
43 */ 43 */
44 ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 44 ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
45 : QDialog( parent, name, modal, fl ) { 45 : QDialog( parent, name, modal, fl ) {
46 46
47 if ( !name ) 47 if ( !name )
48 setName( "ScanDialog" ); 48 setName( "ScanDialog" );
49 resize( 240, 320 ); 49 resize( 240, 320 );
50 setCaption( tr( "Scan for devices" ) ); 50 setCaption( tr( "Scan for devices" ) );
51 51
52 Frame7 = new QFrame( this, "Frame7" ); 52 Frame7 = new QFrame( this, "Frame7" );
53 Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); 53 Frame7->setGeometry( QRect( 0, 0, 240, 331 ) );
54 Frame7->setFrameShape( QFrame::StyledPanel ); 54 Frame7->setFrameShape( QFrame::StyledPanel );
55 Frame7->setFrameShadow( QFrame::Raised ); 55 Frame7->setFrameShadow( QFrame::Raised );
56 56
57 QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); 57 QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" );
58 privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); 58 privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) );
59 Layout11 = new QVBoxLayout( privateLayoutWidget ); 59 Layout11 = new QVBoxLayout( privateLayoutWidget );
60 Layout11->setSpacing( 6 ); 60 Layout11->setSpacing( 6 );
61 Layout11->setMargin( 0 ); 61 Layout11->setMargin( 0 );
62 62
63 progress = new QProgressBar(privateLayoutWidget, "progbar"); 63 progress = new QProgressBar(privateLayoutWidget, "progbar");
64 progress->setTotalSteps(20); 64 progress->setTotalSteps(20);
65 65
66 QFrame *buttonFrame = new QFrame(Frame7, ""); 66 QFrame *buttonFrame = new QFrame(Frame7, "");
67 67
68 StartButton = new QPushButton( buttonFrame, "StartButton" ); 68 StartButton = new QPushButton( buttonFrame, "StartButton" );
69 StartButton->setText( tr( "Start scan" ) ); 69 StartButton->setText( tr( "Start scan" ) );
70 70
71 StopButton = new QPushButton( buttonFrame, "StopButton" ); 71 StopButton = new QPushButton( buttonFrame, "StopButton" );
72 StopButton->setText( tr( "Cancel scan" ) ); 72 StopButton->setText( tr( "Cancel scan" ) );
73 73
74 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); 74 QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
75 75
76 buttonLayout->addWidget(StartButton); 76 buttonLayout->addWidget(StartButton);
77 buttonLayout->addWidget(StopButton); 77 buttonLayout->addWidget(StopButton);
78 78
79 ListView1 = new QListView( privateLayoutWidget, "ListView1" ); 79 ListView1 = new QListView( privateLayoutWidget, "ListView1" );
80 80
81 //ListView1->addColumn( tr( "Add" ) ); 81 //ListView1->addColumn( tr( "Add" ) );
82 ListView1->addColumn( tr( "Add Device" ) ); 82 ListView1->addColumn( tr( "Add Device" ) );
83 //ListView1->addColumn( tr( "Type" ) ); 83 //ListView1->addColumn( tr( "Type" ) );
84 84
85 Layout11->addWidget( ListView1); 85 Layout11->addWidget( ListView1);
86 Layout11->addWidget(progress); 86 Layout11->addWidget(progress);
87 Layout11->addWidget( buttonFrame); 87 Layout11->addWidget( buttonFrame);
88 88
89 localDevice = new Manager( "hci0" ); 89 localDevice = new Manager( "hci0" );
90 90
91 connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); 91 connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
92 connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); 92 connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
93 connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), 93 connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ),
94 this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; 94 this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ;
95 progressStat = 0; 95 progressStat = 0;
96 } 96 }
97 97
98// hack, make cleaner later 98// hack, make cleaner later
99 void ScanDialog::progressTimer() { 99 void ScanDialog::progressTimer() {
100 100
101 progressStat++; 101 progressStat++;
102 if (progressStat++ < 20) { 102 if (progressStat++ < 20) {
103 QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); 103 QTimer::singleShot( 1000, this, SLOT(progressTimer() ) );
104 } 104 }
105 progress->setProgress(progressStat++); 105 progress->setProgress(progressStat++);
106 106
107 } 107 }
108 108
109 void ScanDialog::startSearch() { 109 void ScanDialog::startSearch() {
110 progress->setProgress(0); 110 progress->setProgress(0);
111 progressStat = 0; 111 progressStat = 0;
112 112
113 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); 113 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
114 deviceItem2->setText(1, "BLAH" ); 114 deviceItem2->setText(1, "BLAH" );
115 115
116 progressTimer(); 116 progressTimer();
117 // when finished, it emmite foundDevices() 117 // when finished, it emmite foundDevices()
118 // checken ob initialisiert , qcop ans applet. 118 // checken ob initialisiert , qcop ans applet.
119 localDevice->searchDevices(); 119 localDevice->searchDevices();
120 120
121 } 121 }
122 122
123 void ScanDialog::stopSearch() { 123 void ScanDialog::stopSearch() {
124 124
125 } 125 }
126 126
127 void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { 127 void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) {
128 128
129 QCheckListItem * deviceItem; 129 QCheckListItem * deviceItem;
130 130
131 RemoteDevices::ValueList::Iterator it; 131 RemoteDevices::ValueList::Iterator it;
132 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 132 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
133 133
134 deviceItem = new QCheckListItem( ListView1, (*it).name() ); 134 deviceItem = new QCheckListItem( ListView1, (*it).name() );
135 deviceItem->setText(1, (*it).mac() ); 135 deviceItem->setText(1, (*it).mac() );
136 } 136 }
137
138 } 137 }
139 138
140/* 139/*
141 * Iterates trough the items, and collects the checked items. 140 * Iterates trough the items, and collects the checked items.
142 * Then it emits it, so the manager can connect to the signal to fill the listing. 141 * Then it emits it, so the manager can connect to the signal to fill the listing.
143 */ 142 */
144 void ScanDialog::emitToManager() { 143 void ScanDialog::emitToManager() {
145 144
146 if (!ListView1) { 145 if (!ListView1) {
147 return; 146 return;
148 } 147 }
149 148
150 QList<RemoteDevices> *deviceList = new QList<RemoteDevices>; 149 QList<RemoteDevices> *deviceList = new QList<RemoteDevices>;
151 150
152 QListViewItemIterator it( ListView1 ); 151 QListViewItemIterator it( ListView1 );
153 for ( ; it.current(); ++it ) { 152 for ( ; it.current(); ++it ) {
154 if ( it.current()->isSelected() ) { 153 if ( ((QCheckListItem*)it.current())->isOn() ) {
155 RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0)); 154 RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0));
156 deviceList->append( device ); 155 deviceList->append( device );
157 } 156 }
158 } 157 }
159 emit selectedDevices( *deviceList ); 158 emit selectedDevices( *deviceList );
160 } 159 }
161 160
162/* 161/*
163 * Cleanup 162 * Cleanup
164 */ 163 */
165 ScanDialog::~ScanDialog() { 164 ScanDialog::~ScanDialog() {
166 emitToManager(); 165 emitToManager();
167 delete localDevice; 166 delete localDevice;
168 } 167 }
169 168
170} 169}
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h
index 4785a62..0ca302a 100644
--- a/noncore/net/opietooth/manager/scandialog.h
+++ b/noncore/net/opietooth/manager/scandialog.h
@@ -1,77 +1,77 @@
1/* main.cpp 1/* main.cpp
2 * 2 *
3 * copyright : (c) 2002 by Maximilian Reiß 3 * copyright : (c) 2002 by Maximilian Reiß
4 * email : max.reiss@gmx.de 4 * email : max.reiss@gmx.de
5 * 5 *
6 */ 6 */
7/*************************************************************************** 7/***************************************************************************
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 * * 13 * *
14 ***************************************************************************/ 14 ***************************************************************************/
15 15
16 16
17#ifndef SCANDIALOG_H 17#ifndef SCANDIALOG_H
18#define SCANDIALOG_H 18#define SCANDIALOG_H
19 19
20#include <qvariant.h> 20#include <qvariant.h>
21#include <qdialog.h> 21#include <qdialog.h>
22#include <qlist.h> 22#include <qlist.h>
23 23
24 24#include <remotedevice.h>
25class QVBoxLayout; 25class QVBoxLayout;
26class QHBoxLayout; 26class QHBoxLayout;
27class QGridLayout; 27class QGridLayout;
28class QFrame; 28class QFrame;
29class QLabel; 29class QLabel;
30class QListView; 30class QListView;
31class QListViewItem; 31class QListViewItem;
32class QPushButton; 32class QPushButton;
33class QProgressBar; 33class QProgressBar;
34 34
35 35
36namespace OpieTooth { 36namespace OpieTooth {
37 37
38#include <remotedevices.h> 38
39class Manager; 39class Manager;
40class Device; 40class Device;
41 41
42 class ScanDialog : public QDialog { 42 class ScanDialog : public QDialog {
43 Q_OBJECT 43 Q_OBJECT
44 44
45 public: 45 public:
46 ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 46 ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
47 ~ScanDialog(); 47 ~ScanDialog();
48 48
49 QFrame* Frame7; 49 QFrame* Frame7;
50 QProgressBar* progress; 50 QProgressBar* progress;
51 QPushButton* StartButton; 51 QPushButton* StartButton;
52 QPushButton* StopButton; 52 QPushButton* StopButton;
53 QListView* ListView1; 53 QListView* ListView1;
54 54
55 55
56 protected: 56 protected:
57 QVBoxLayout* Layout11; 57 QVBoxLayout* Layout11;
58 58
59 private slots: 59 private slots:
60 void stopSearch(); 60 void stopSearch();
61 void startSearch(); 61 void startSearch();
62 void progressTimer(); 62 void progressTimer();
63 void fillList(const QString& device, RemoteDevices::ValueList list); 63 void fillList(const QString& device, RemoteDevices::ValueList list);
64 64
65 private: 65 private:
66 void emitToManager(); 66 void emitToManager();
67 Manager *localDevice; 67 Manager *localDevice;
68 int progressStat; 68 int progressStat;
69 69
70 signals: 70 signals:
71 void selectedDevices(QList<RemoteDevices>&); 71 void selectedDevices(QList<RemoteDevices>&);
72 }; 72 };
73 73
74 74
75} 75}
76 76
77#endif // SCANDIALOG_H 77#endif // SCANDIALOG_H