summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/manager.cc
Unidiff
Diffstat (limited to 'noncore/net/opietooth/lib/manager.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc99
1 files changed, 82 insertions, 17 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 882af81..eeeab19 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1 +1,2 @@
1#include <opie/oprocess.h>
1 2
@@ -6,6 +7,8 @@ using namespace OpieTooth;
6 7
7Manager::Manager( const QString& ) 8Manager::Manager( const QString& dev )
8 : QObject() 9 : QObject()
9{ 10{
10 11 m_device = dev;
12 m_hcitool = 0;
13 m_sdp = 0;
11} 14}
@@ -14,3 +17,4 @@ Manager::Manager( Device* dev )
14{ 17{
15 18 m_hcitool = 0;
19 m_sdp = 0;
16} 20}
@@ -19,9 +23,11 @@ Manager::Manager()
19{ 23{
20 24 m_hcitool = 0;
25 m_sdp = 0;
21} 26}
22Manager::~Manager(){ 27Manager::~Manager(){
23 28 delete m_hcitool;
29 delete m_sdp;
24} 30}
25void Manager::setDevice( const QString& dev ){ 31void Manager::setDevice( const QString& dev ){
26 32 m_device = dev;
27} 33}
@@ -31,2 +37,11 @@ void Manager::setDevice( Device* dev ){
31void Manager::isConnected( const QString& device ){ 37void Manager::isConnected( const QString& device ){
38 OProcess* l2ping = new OProcess();
39 l2ping->setName( device.latin1() );
40 *l2ping << "l2ping" << "-c1" << device;
41 connect(l2ping, SIGNAL(processExited(OProcess* ) ),
42 this, SLOT(slotProcessExited(OProcess*) ) );
43 if (!l2ping->start() ) {
44 emit connected( device, false );
45 delete l2ping;
46 }
32 47
@@ -46,24 +61,74 @@ void Manager::searchDevices(Device* d ){
46void Manager::addService(const QString& name ){ 61void Manager::addService(const QString& name ){
47 62 OProcess proc;
48} 63 proc << "sdptool" << "add" << name;
49void Manager::addServices(const QStringList& ){ 64 bool bo = true;
50 65 if (!proc.start(OProcess::DontCare ) )
66 bo = false;
67 emit addedService( name, bo );
68}
69void Manager::addServices(const QStringList& list){
70 QStringList::ConstIterator it;
71 for (it = list.begin(); it != list.end(); ++it )
72 addService( (*it) );
51} 73}
52void Manager::removeService( const QString& name ){ 74void Manager::removeService( const QString& name ){
53 75 OProcess prc;
54} 76 prc << "sdptool" << "del" << name;
55void Manager::removeServices( const QStringList& ){ 77 bool bo = true;
56 78 if (!prc.start(OProcess::DontCare ) )
79 bo = false;
80 emit removedService( name, bo );
81}
82void Manager::removeServices( const QStringList& list){
83 QStringList::ConstIterator it;
84 for (it = list.begin(); it != list.end(); ++it )
85 removeService( (*it) );
57} 86}
58void Manager::searchServices( const QString& remDevice ){ 87void Manager::searchServices( const QString& remDevice ){
88 OProcess *m_sdp =new OProcess();
89 *m_sdp << "sdptool" << "browse" << remDevice;
90 m_sdp->setName( remDevice.latin1() );
91 connect(m_sdp, SIGNAL(processExited(OProcess*) ),
92 this, SLOT(slotSDPExited(OProcess* ) ) );
93 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
94 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
95 if (!m_sdp->start() ) {
96 delete m_sdp;
97 Services::ValueList list;
98 emit foundServices( remDevice, list );
99 }
100}
101void Manager::searchServices( const RemoteDevices& dev){
102 searchServices( dev.mac() );
103}
104QString Manager::toDevice( const QString& mac ){
59 105
60} 106}
61void Manager::searchServices( const RemoteDevices& ){ 107QString Manager::toMac( const QString &device ){
62 108
63} 109}
64QString Manager::toDevice( const QString& mac ){ 110void Manager::slotProcessExited(OProcess* proc ) {
111 bool conn= false;
112 if (proc->normalExit() && proc->exitStatus() == 0 )
113 conn = true;
65 114
115 QString name = QString::fromLatin1(proc->name() );
116 emit connected( name, conn );
117 delete proc;
66} 118}
67QString Manager::toMac( const QString &device ){ 119void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
120{
121 QCString str(ch, len+1 );
122 QMap<QString, QString>::Iterator it;
123 it = m_out.find(proc->name() );
124 if ( it != m_out.end() ) {
125 QString string = it.data();
126 string.append( str );
127 m_out.replace( proc->name(), string );
128 }
68 129
69} 130}
131void Manager::slotSDPExited( OProcess* proc)
132{
133 delete proc;
134}