summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/manager.cc
authorzecke <zecke>2002-06-15 20:06:04 (UTC)
committer zecke <zecke>2002-06-15 20:06:04 (UTC)
commitb15f8a613d83a2f3957fef515e20981f636b908b (patch) (unidiff)
tree6d2e6743ceb4c3cb299944efc4b2925e5f40412d /noncore/net/opietooth/lib/manager.cc
parentef75752efaef84e4b7350f9768f3cb3c4fd744af (diff)
downloadopie-b15f8a613d83a2f3957fef515e20981f636b908b.zip
opie-b15f8a613d83a2f3957fef515e20981f636b908b.tar.gz
opie-b15f8a613d83a2f3957fef515e20981f636b908b.tar.bz2
isCOnnected, add and remove Service + first bits of service browsing done
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,37 +1,52 @@
1#include <opie/oprocess.h>
1 2
2#include "manager.h" 3#include "manager.h"
3 4
4 5
5using namespace OpieTooth; 6using 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}
12Manager::Manager( Device* dev ) 15Manager::Manager( Device* dev )
13 : QObject() 16 : QObject()
14{ 17{
15 18 m_hcitool = 0;
19 m_sdp = 0;
16} 20}
17Manager::Manager() 21Manager::Manager()
18 : QObject() 22 : QObject()
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}
28void Manager::setDevice( Device* dev ){ 34void Manager::setDevice( Device* dev ){
29 35
30} 36}
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
33} 48}
34void Manager::isConnected( Device* dev ){ 49void Manager::isConnected( Device* dev ){
35 50
36 51
37} 52}
@@ -41,29 +56,79 @@ void Manager::searchDevices( const QString& device ){
41 56
42void Manager::searchDevices(Device* d ){ 57void Manager::searchDevices(Device* d ){
43 58
44 59
45} 60}
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}