author | zecke <zecke> | 2002-06-15 20:06:04 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-15 20:06:04 (UTC) |
commit | b15f8a613d83a2f3957fef515e20981f636b908b (patch) (unidiff) | |
tree | 6d2e6743ceb4c3cb299944efc4b2925e5f40412d /noncore/net/opietooth/lib/manager.cc | |
parent | ef75752efaef84e4b7350f9768f3cb3c4fd744af (diff) | |
download | opie-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) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 99 |
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 | ||
7 | Manager::Manager( const QString& ) | 8 | Manager::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 | } |
22 | Manager::~Manager(){ | 27 | Manager::~Manager(){ |
23 | 28 | delete m_hcitool; | |
29 | delete m_sdp; | ||
24 | } | 30 | } |
25 | void Manager::setDevice( const QString& dev ){ | 31 | void Manager::setDevice( const QString& dev ){ |
26 | 32 | m_device = dev; | |
27 | } | 33 | } |
@@ -31,2 +37,11 @@ void Manager::setDevice( Device* dev ){ | |||
31 | void Manager::isConnected( const QString& device ){ | 37 | void 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 ){ | |||
46 | void Manager::addService(const QString& name ){ | 61 | void Manager::addService(const QString& name ){ |
47 | 62 | OProcess proc; | |
48 | } | 63 | proc << "sdptool" << "add" << name; |
49 | void Manager::addServices(const QStringList& ){ | 64 | bool bo = true; |
50 | 65 | if (!proc.start(OProcess::DontCare ) ) | |
66 | bo = false; | ||
67 | emit addedService( name, bo ); | ||
68 | } | ||
69 | void Manager::addServices(const QStringList& list){ | ||
70 | QStringList::ConstIterator it; | ||
71 | for (it = list.begin(); it != list.end(); ++it ) | ||
72 | addService( (*it) ); | ||
51 | } | 73 | } |
52 | void Manager::removeService( const QString& name ){ | 74 | void Manager::removeService( const QString& name ){ |
53 | 75 | OProcess prc; | |
54 | } | 76 | prc << "sdptool" << "del" << name; |
55 | void Manager::removeServices( const QStringList& ){ | 77 | bool bo = true; |
56 | 78 | if (!prc.start(OProcess::DontCare ) ) | |
79 | bo = false; | ||
80 | emit removedService( name, bo ); | ||
81 | } | ||
82 | void Manager::removeServices( const QStringList& list){ | ||
83 | QStringList::ConstIterator it; | ||
84 | for (it = list.begin(); it != list.end(); ++it ) | ||
85 | removeService( (*it) ); | ||
57 | } | 86 | } |
58 | void Manager::searchServices( const QString& remDevice ){ | 87 | void 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 | } | ||
101 | void Manager::searchServices( const RemoteDevices& dev){ | ||
102 | searchServices( dev.mac() ); | ||
103 | } | ||
104 | QString Manager::toDevice( const QString& mac ){ | ||
59 | 105 | ||
60 | } | 106 | } |
61 | void Manager::searchServices( const RemoteDevices& ){ | 107 | QString Manager::toMac( const QString &device ){ |
62 | 108 | ||
63 | } | 109 | } |
64 | QString Manager::toDevice( const QString& mac ){ | 110 | void 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; | ||
118 | } | ||
119 | void 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 ); | ||
66 | } | 128 | } |
67 | QString Manager::toMac( const QString &device ){ | ||
68 | 129 | ||
69 | } | 130 | } |
131 | void Manager::slotSDPExited( OProcess* proc) | ||
132 | { | ||
133 | delete proc; | ||
134 | } | ||