-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 54 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/device.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/lib.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/remotedevice.cc | 48 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/remotedevice.h | 6 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.cc | 168 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.h | 18 |
8 files changed, 286 insertions, 16 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index 468f191..e3d7f3b 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc | |||
@@ -9,4 +9,20 @@ using namespace OpieTooth; | |||
9 | 9 | ||
10 | namespace { | ||
11 | int parsePid( const QCString& par ){ | ||
12 | int id=0; | ||
13 | QString string( par ); | ||
14 | QStringList list = QStringList::split( '\n', string ); | ||
15 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ | ||
16 | if( !(*it).startsWith("CSR") ){ | ||
17 | id = (*it).toInt(); | ||
18 | break; | ||
19 | } | ||
20 | } | ||
21 | return id; | ||
22 | } | ||
23 | } | ||
24 | |||
10 | Device::Device(const QString &device, const QString &mode ) | 25 | Device::Device(const QString &device, const QString &mode ) |
11 | : QObject(0, "device" ) { | 26 | : QObject(0, "device" ) { |
27 | qWarning("OpieTooth::Device create" ); | ||
12 | m_hci = 0; | 28 | m_hci = 0; |
@@ -22,3 +38,6 @@ Device::~Device(){ | |||
22 | void Device::attach(){ | 38 | void Device::attach(){ |
23 | if(m_process != 0 ){ | 39 | qWarning("attaching %s %s", m_device.latin1(), m_mode.latin1() ); |
40 | if(m_process == 0 ){ | ||
41 | m_output.resize(0); | ||
42 | qWarning("new process to create" ); | ||
24 | m_process = new KProcess(); | 43 | m_process = new KProcess(); |
@@ -34,2 +53,3 @@ void Device::attach(){ | |||
34 | if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){ | 53 | if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){ |
54 | qWarning("Could not start" ); | ||
35 | delete m_process; | 55 | delete m_process; |
@@ -43,5 +63,8 @@ void Device::detach(){ | |||
43 | // kill the pid we got | 63 | // kill the pid we got |
44 | if(m_attached ) | 64 | if(m_attached ){ |
45 | //kill the pid | 65 | //kill the pid |
66 | qWarning( "killing" ); | ||
46 | kill(pid, 9); | 67 | kill(pid, 9); |
68 | } | ||
69 | qWarning("detached" ); | ||
47 | } | 70 | } |
@@ -55,2 +78,3 @@ void Device::slotExited( KProcess* proc) | |||
55 | { | 78 | { |
79 | qWarning("prcess exited" ); | ||
56 | if(proc== m_process ){ | 80 | if(proc== m_process ){ |
@@ -59,2 +83,6 @@ void Device::slotExited( KProcess* proc) | |||
59 | if( ret == 0 ){ // attached | 83 | if( ret == 0 ){ // attached |
84 | qWarning("attached" ); | ||
85 | qWarning("Output: %s", m_output.data() ); | ||
86 | pid = parsePid( m_output ); | ||
87 | qWarning("Pid = %d", pid ); | ||
60 | // now hciconfig hci0 up ( determine hciX FIXME) | 88 | // now hciconfig hci0 up ( determine hciX FIXME) |
@@ -67,2 +95,7 @@ void Device::slotExited( KProcess* proc) | |||
67 | this, SLOT( slotExited(KProcess* ) ) ); | 95 | this, SLOT( slotExited(KProcess* ) ) ); |
96 | if(!m_hci->start() ){ | ||
97 | qWarning("could not start" ); | ||
98 | m_attached = false; | ||
99 | emit device("hci0", false ); | ||
100 | } | ||
68 | }else{ | 101 | }else{ |
@@ -76,7 +109,12 @@ void Device::slotExited( KProcess* proc) | |||
76 | }else if(proc== m_hci ){ | 109 | }else if(proc== m_hci ){ |
110 | qWarning("M HCI exited" ); | ||
77 | if( m_hci->normalExit() ){ | 111 | if( m_hci->normalExit() ){ |
78 | int ret = m_hci->normalExit(); | 112 | qWarning("normal exit" ); |
113 | int ret = m_hci->exitStatus(); | ||
79 | if( ret == 0 ){ | 114 | if( ret == 0 ){ |
115 | qWarning("attached really really attached" ); | ||
116 | m_attached = true; | ||
80 | emit device("hci0", true ); | 117 | emit device("hci0", true ); |
81 | }else{ | 118 | }else{ |
119 | qWarning( "failed" ); | ||
82 | emit device("hci0", false ); | 120 | emit device("hci0", false ); |
@@ -91,2 +129,3 @@ void Device::slotStdOut(KProcess* proc, char* chars, int len) | |||
91 | { | 129 | { |
130 | qWarning("std out" ); | ||
92 | if( len <1 ) | 131 | if( len <1 ) |
@@ -94,6 +133,5 @@ void Device::slotStdOut(KProcess* proc, char* chars, int len) | |||
94 | if(proc == m_process ){ | 133 | if(proc == m_process ){ |
95 | QCString string( chars, len+1 ); | 134 | QCString string( chars, len+1 ); // \0 == +1 |
96 | if(string.left(3) != "CSR" ){ // it's the pid | 135 | qWarning("output: %s", string.data() ); |
97 | pid = string.toInt(); | 136 | m_output.append( string.data() ); |
98 | }; | ||
99 | } | 137 | } |
@@ -102,3 +140,3 @@ void Device::slotStdErr(KProcess*, char*, int ) | |||
102 | { | 140 | { |
103 | 141 | qWarning("std err" ); | |
104 | } | 142 | } |
diff --git a/noncore/net/opietooth/lib/device.h b/noncore/net/opietooth/lib/device.h index 010db40..8498b14 100644 --- a/noncore/net/opietooth/lib/device.h +++ b/noncore/net/opietooth/lib/device.h | |||
@@ -80,2 +80,3 @@ namespace OpieTooth { | |||
80 | pid_t pid; | 80 | pid_t pid; |
81 | QCString m_output; | ||
81 | }; | 82 | }; |
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro index 7cededf..a70c7ab 100644 --- a/noncore/net/opietooth/lib/lib.pro +++ b/noncore/net/opietooth/lib/lib.pro | |||
@@ -2,4 +2,4 @@ TEMPLATE = lib | |||
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = kprocctrl.h kprocess.h device.h | 3 | HEADERS = kprocctrl.h kprocess.h device.h manager.h remotedevice.h services.h |
4 | SOURCES = kprocctrl.cpp kprocess.cpp device.cc | 4 | SOURCES = kprocctrl.cpp kprocess.cpp device.cc manager.cc remotedevice.cc services.cc |
5 | TARGET = opietooth | 5 | TARGET = opietooth |
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 5586680..6c5e27f 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -8,2 +8,5 @@ | |||
8 | 8 | ||
9 | #include "remotedevice.h" | ||
10 | #include "services.h" | ||
11 | |||
9 | namespace OpieTooth { | 12 | namespace OpieTooth { |
diff --git a/noncore/net/opietooth/lib/remotedevice.cc b/noncore/net/opietooth/lib/remotedevice.cc new file mode 100644 index 0000000..0045904 --- a/dev/null +++ b/noncore/net/opietooth/lib/remotedevice.cc | |||
@@ -0,0 +1,48 @@ | |||
1 | |||
2 | #include "remotedevice.h" | ||
3 | |||
4 | using namespace OpieTooth; | ||
5 | |||
6 | bool operator==(const RemoteDevices& rem1, const RemoteDevices& rem2){ | ||
7 | if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) ) | ||
8 | return true; | ||
9 | |||
10 | return false; | ||
11 | } | ||
12 | |||
13 | RemoteDevices::RemoteDevices(){ | ||
14 | |||
15 | } | ||
16 | RemoteDevices::RemoteDevices(const RemoteDevices& ole ){ | ||
17 | (*this) = ole; | ||
18 | } | ||
19 | RemoteDevices::RemoteDevices(const QString &mac, const QString& name ){ | ||
20 | m_mac = mac; | ||
21 | m_name = name; | ||
22 | } | ||
23 | RemoteDevices::~RemoteDevices(){ | ||
24 | |||
25 | } | ||
26 | bool RemoteDevices::isEmpty() const { | ||
27 | if( m_name.isEmpty() && m_mac.isEmpty() ) | ||
28 | return true; | ||
29 | return false; | ||
30 | }; | ||
31 | RemoteDevices& RemoteDevices::operator=( const RemoteDevices& rem1){ | ||
32 | m_name = rem1.m_name; | ||
33 | m_mac = rem1.m_mac; | ||
34 | return *this; | ||
35 | |||
36 | } | ||
37 | QString RemoteDevices::mac() const { | ||
38 | return m_mac; | ||
39 | } | ||
40 | void RemoteDevices::setMac( const QString& mac ){ | ||
41 | m_mac = mac; | ||
42 | } | ||
43 | QString RemoteDevices::name() const{ | ||
44 | return m_name; | ||
45 | } | ||
46 | void RemoteDevices::setName( const QString& name ){ | ||
47 | m_name = name; | ||
48 | } | ||
diff --git a/noncore/net/opietooth/lib/remotedevice.h b/noncore/net/opietooth/lib/remotedevice.h index 8e5baa5..96a27de 100644 --- a/noncore/net/opietooth/lib/remotedevice.h +++ b/noncore/net/opietooth/lib/remotedevice.h | |||
@@ -15,3 +15,4 @@ namespace OpieTooth{ | |||
15 | friend bool operator==(const RemoteDevices&, const RemoteDevices&); | 15 | friend bool operator==(const RemoteDevices&, const RemoteDevices&); |
16 | RemoteDevies &operator=(const RemoteDevices& ); | 16 | RemoteDevices &operator=(const RemoteDevices& ); |
17 | bool isEmpty()const; | ||
17 | QString mac()const; | 18 | QString mac()const; |
@@ -20,2 +21,5 @@ namespace OpieTooth{ | |||
20 | void setName( const QString& name ); | 21 | void setName( const QString& name ); |
22 | private: | ||
23 | QString m_name; | ||
24 | QString m_mac; | ||
21 | }; | 25 | }; |
diff --git a/noncore/net/opietooth/lib/services.cc b/noncore/net/opietooth/lib/services.cc new file mode 100644 index 0000000..75c1bd6 --- a/dev/null +++ b/noncore/net/opietooth/lib/services.cc | |||
@@ -0,0 +1,168 @@ | |||
1 | |||
2 | #include "services.h" | ||
3 | |||
4 | using namespace OpieTooth; | ||
5 | |||
6 | |||
7 | Services::ProfileDescriptor::ProfileDescriptor(){ | ||
8 | |||
9 | } | ||
10 | Services::ProfileDescriptor::ProfileDescriptor(const QString &id, uint idInt, uint version ){ | ||
11 | m_id = id; | ||
12 | m_idInt = idInt; | ||
13 | m_version = version; | ||
14 | } | ||
15 | Services::ProfileDescriptor::ProfileDescriptor( const ProfileDescriptor& rem){ | ||
16 | (*this) = rem; | ||
17 | } | ||
18 | QString Services::ProfileDescriptor::id() const { | ||
19 | return m_id; | ||
20 | } | ||
21 | void Services::ProfileDescriptor::setId( const QString& id ){ | ||
22 | m_id = id; | ||
23 | } | ||
24 | void Services::ProfileDescriptor::setId(uint id ){ | ||
25 | m_idInt = id; | ||
26 | } | ||
27 | uint Services::ProfileDescriptor::idInt()const{ | ||
28 | return m_idInt; | ||
29 | } | ||
30 | uint Services::ProfileDescriptor::version() const{ | ||
31 | return m_version; | ||
32 | } | ||
33 | void Services::ProfileDescriptor::setVersion(uint version){ | ||
34 | m_version = version; | ||
35 | } | ||
36 | Services::ProfileDescriptor& Services::ProfileDescriptor::operator=( const Services::ProfileDescriptor& prof){ | ||
37 | m_id = prof.m_id; | ||
38 | m_idInt = prof.m_idInt; | ||
39 | m_version = prof.m_version; | ||
40 | return *this; | ||
41 | } | ||
42 | bool operator==(const Services::ProfileDescriptor& first, | ||
43 | const Services::ProfileDescriptor& second ){ | ||
44 | |||
45 | if( (first.id() == second.id() ) && | ||
46 | (first.version() == second.version() ) && | ||
47 | (first.idInt() == second.idInt() ) ) | ||
48 | return true; | ||
49 | return false; | ||
50 | } | ||
51 | |||
52 | Services::ProtocolDescriptor::ProtocolDescriptor(){ | ||
53 | m_number = 0; | ||
54 | m_channel = 0; | ||
55 | } | ||
56 | Services::ProtocolDescriptor::ProtocolDescriptor(const QString& name, | ||
57 | uint number, | ||
58 | uint channel){ | ||
59 | m_name = name; | ||
60 | m_number = number; | ||
61 | m_channel = channel; | ||
62 | } | ||
63 | Services::ProtocolDescriptor::ProtocolDescriptor( const ProtocolDescriptor& ole ){ | ||
64 | (*this) = ole; | ||
65 | } | ||
66 | Services::ProtocolDescriptor::~ProtocolDescriptor(){ | ||
67 | |||
68 | } | ||
69 | QString Services::ProtocolDescriptor::name() const{ | ||
70 | return m_name; | ||
71 | } | ||
72 | void Services::ProtocolDescriptor::setName(const QString& name ){ | ||
73 | m_name = name; | ||
74 | } | ||
75 | uint Services::ProtocolDescriptor::id()const { | ||
76 | return m_number; | ||
77 | } | ||
78 | void Services::ProtocolDescriptor::setId( uint id ){ | ||
79 | m_number = id; | ||
80 | } | ||
81 | uint Services::ProtocolDescriptor::port()const { | ||
82 | return m_channel; | ||
83 | } | ||
84 | void Services::ProtocolDescriptor::setPort( uint port ){ | ||
85 | m_channel = port; | ||
86 | } | ||
87 | Services::ProtocolDescriptor &Services::ProtocolDescriptor::operator=( const Services::ProtocolDescriptor& desc ){ | ||
88 | m_name = desc.m_name; | ||
89 | m_channel = desc.m_channel; | ||
90 | m_number = desc.m_number; | ||
91 | return *this; | ||
92 | } | ||
93 | bool operator==( const Services::ProtocolDescriptor &first, | ||
94 | const Services::ProtocolDescriptor &second ){ | ||
95 | if( ( first.name() == second.name() ) && | ||
96 | ( first.id() == second.id() ) && | ||
97 | ( first.port() == second.port() ) ) | ||
98 | return true; | ||
99 | |||
100 | return false; | ||
101 | |||
102 | } | ||
103 | |||
104 | Services::Services(){ | ||
105 | |||
106 | } | ||
107 | Services::Services(const Services& service ){ | ||
108 | |||
109 | } | ||
110 | Services::~Services(){ | ||
111 | |||
112 | } | ||
113 | Services &Services::operator=( const Services& ){ | ||
114 | return *this; | ||
115 | } | ||
116 | bool operator==( const Services&, | ||
117 | const Services& ){ | ||
118 | return false; | ||
119 | } | ||
120 | QString Services::serviceName() const{ | ||
121 | |||
122 | } | ||
123 | void Services::setServiceName( const QString& service ){ | ||
124 | |||
125 | } | ||
126 | int Services::recHandle() const{ | ||
127 | |||
128 | } | ||
129 | void Services::setRecHandle( int ){ | ||
130 | |||
131 | } | ||
132 | QString Services::classIdList() const{ | ||
133 | |||
134 | } | ||
135 | void Services::setClassIdList( const QString& ){ | ||
136 | |||
137 | } | ||
138 | int Services::classIdListInt() const{ | ||
139 | |||
140 | } | ||
141 | void Services::setClassIdList(int ){ | ||
142 | |||
143 | } | ||
144 | void Services::insertProtocolDescriptor( const ProtocolDescriptor& ){ | ||
145 | |||
146 | } | ||
147 | void Services::clearProtocolDescriptorList(){ | ||
148 | |||
149 | } | ||
150 | void Services::removeProtocolDescriptor( const ProtocolDescriptor& ){ | ||
151 | |||
152 | } | ||
153 | Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ | ||
154 | |||
155 | } | ||
156 | |||
157 | void Services::insertProfileDescriptor( const ProfileDescriptor& ){ | ||
158 | |||
159 | } | ||
160 | void Services::clearProfileDescriptorList(){ | ||
161 | |||
162 | } | ||
163 | void Services::removeProfileDescriptor( const ProfileDescriptor& ){ | ||
164 | |||
165 | } | ||
166 | Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ | ||
167 | |||
168 | } | ||
diff --git a/noncore/net/opietooth/lib/services.h b/noncore/net/opietooth/lib/services.h index 4a4dea8..8e9378a 100644 --- a/noncore/net/opietooth/lib/services.h +++ b/noncore/net/opietooth/lib/services.h | |||
@@ -16,3 +16,3 @@ namespace OpieTooth { | |||
16 | */ | 16 | */ |
17 | class ProfileDesriptor{ | 17 | class ProfileDescriptor{ |
18 | public: | 18 | public: |
@@ -61,3 +61,3 @@ namespace OpieTooth { | |||
61 | */ | 61 | */ |
62 | ProfileDescriptor &operator=( const ProfileDescriptor ); | 62 | ProfileDescriptor &operator=( const ProfileDescriptor& ); |
63 | /** | 63 | /** |
@@ -66,2 +66,6 @@ namespace OpieTooth { | |||
66 | friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); | 66 | friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); |
67 | private: | ||
68 | QString m_id; | ||
69 | uint m_idInt; | ||
70 | uint m_version; | ||
67 | }; | 71 | }; |
@@ -83,3 +87,3 @@ namespace OpieTooth { | |||
83 | ProtocolDescriptor(const QString&, uint, uint channel ); // Q_UINT8 ? | 87 | ProtocolDescriptor(const QString&, uint, uint channel ); // Q_UINT8 ? |
84 | ProtocolDescriptot(const ProtocolDescriptor& ); | 88 | ProtocolDescriptor(const ProtocolDescriptor& ); |
85 | ~ProtocolDescriptor(); | 89 | ~ProtocolDescriptor(); |
@@ -92,4 +96,8 @@ namespace OpieTooth { | |||
92 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); | 96 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); |
93 | friend bool operator==( const ProtocolDescription&, | 97 | friend bool operator==( const ProtocolDescriptor&, |
94 | const ProtocolDescription& ); | 98 | const ProtocolDescriptor& ); |
99 | private: | ||
100 | QString m_name; | ||
101 | uint m_number; | ||
102 | uint m_channel; | ||
95 | }; | 103 | }; |