-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 127b0af..a1d64a4 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -74,128 +74,132 @@ namespace OpieTooth { | |||
74 | btManager = 0; | 74 | btManager = 0; |
75 | bluezactive = false; | 75 | bluezactive = false; |
76 | bluezDiscoveryActive = false; | 76 | bluezDiscoveryActive = false; |
77 | doListDevice = false; | 77 | doListDevice = false; |
78 | isScanning = false; | 78 | isScanning = false; |
79 | m_wasOn = false; | 79 | m_wasOn = false; |
80 | m_sync = false; | 80 | m_sync = false; |
81 | 81 | ||
82 | // TODO: determine whether this channel has to be closed at destruction time. | 82 | // TODO: determine whether this channel has to be closed at destruction time. |
83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | 83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); |
84 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 84 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
85 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 85 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
86 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 86 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
87 | } | 87 | } |
88 | 88 | ||
89 | BluezApplet::~BluezApplet() { | 89 | BluezApplet::~BluezApplet() { |
90 | if ( btDevice ) { | 90 | if ( btDevice ) { |
91 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 91 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
92 | delete btDevice; | 92 | delete btDevice; |
93 | } | 93 | } |
94 | if ( btManager ) { | 94 | if ( btManager ) { |
95 | delete btManager; | 95 | delete btManager; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | int BluezApplet::position() | 99 | int BluezApplet::position() |
100 | { | 100 | { |
101 | return 6; | 101 | return 6; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | bool BluezApplet::checkBluezStatus() { | 105 | bool BluezApplet::checkBluezStatus() { |
106 | if (btDevice) { | 106 | if (btDevice) { |
107 | if (btDevice->isLoaded() ) { | 107 | if (btDevice->isLoaded() ) { |
108 | odebug << "btDevice isLoaded" << oendl; | 108 | odebug << "btDevice isLoaded" << oendl; |
109 | return true; | 109 | return true; |
110 | } else { | 110 | } else { |
111 | odebug << "btDevice is NOT loaded" << oendl; | 111 | odebug << "btDevice is NOT loaded" << oendl; |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | } else { | 114 | } else { |
115 | odebug << "btDevice is ZERO" << oendl; | 115 | odebug << "btDevice is ZERO" << oendl; |
116 | return false; | 116 | return false; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | int BluezApplet::setBluezStatus(int c, bool sync) { | 120 | int BluezApplet::setBluezStatus(int c, bool sync) { |
121 | 121 | ||
122 | if ( c == 1 ) { | 122 | if ( c == 1 ) { |
123 | switch ( ODevice::inst()->model() ) { | 123 | switch ( ODevice::inst()->model() ) { |
124 | case Model_iPAQ_H39xx: | 124 | case Model_iPAQ_H39xx: |
125 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 125 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
126 | break; | 126 | break; |
127 | 127 | ||
128 | case Model_iPAQ_H5xxx: | 128 | case Model_iPAQ_H5xxx: |
129 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 129 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
130 | break; | 130 | break; |
131 | 131 | ||
132 | #if OPIE_VERSION >= 102010 | 132 | #if OPIE_VERSION >= 102010 |
133 | case Model_MyPal_716: | 133 | case Model_MyPal_716: |
134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
135 | break; | 135 | break; |
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | case Model_iPAQ_H22xx: | ||
139 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | ||
140 | break; | ||
141 | |||
138 | default: | 142 | default: |
139 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 143 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
140 | break; | 144 | break; |
141 | } | 145 | } |
142 | m_sync = sync; | 146 | m_sync = sync; |
143 | connect(btDevice, SIGNAL(device(const QString&, bool)), | 147 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
144 | this, SLOT(slotDevice(const QString&, bool))); | 148 | this, SLOT(slotDevice(const QString&, bool))); |
145 | 149 | ||
146 | } else { | 150 | } else { |
147 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 151 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
148 | if ( btManager ) { | 152 | if ( btManager ) { |
149 | delete btManager; | 153 | delete btManager; |
150 | btManager = 0; | 154 | btManager = 0; |
151 | } | 155 | } |
152 | if ( btDevice ) { | 156 | if ( btDevice ) { |
153 | delete btDevice; | 157 | delete btDevice; |
154 | btDevice = 0; | 158 | btDevice = 0; |
155 | } | 159 | } |
156 | } | 160 | } |
157 | return 0; | 161 | return 0; |
158 | } | 162 | } |
159 | 163 | ||
160 | int BluezApplet::checkBluezDiscoveryStatus() { | 164 | int BluezApplet::checkBluezDiscoveryStatus() { |
161 | return isScanning; | 165 | return isScanning; |
162 | } | 166 | } |
163 | 167 | ||
164 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 168 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
165 | return bluezDiscoveryActive = d; | 169 | return bluezDiscoveryActive = d; |
166 | } | 170 | } |
167 | 171 | ||
168 | // FIXME mbhaynie | 172 | // FIXME mbhaynie |
169 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 173 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
170 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 174 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
171 | { | 175 | { |
172 | if ( str == "enableBluetooth()") { | 176 | if ( str == "enableBluetooth()") { |
173 | m_wasOn = checkBluezStatus(); | 177 | m_wasOn = checkBluezStatus(); |
174 | if (!m_wasOn) { | 178 | if (!m_wasOn) { |
175 | setBluezStatus(1, true); | 179 | setBluezStatus(1, true); |
176 | sleep(2); | 180 | sleep(2); |
177 | } | 181 | } |
178 | } | 182 | } |
179 | else if ( str == "disableBluetooth()") { | 183 | else if ( str == "disableBluetooth()") { |
180 | /* | 184 | /* |
181 | * We can down BT only if it was started by qcop. We don't want | 185 | * We can down BT only if it was started by qcop. We don't want |
182 | * to down BT started from menu an break our networking connection | 186 | * to down BT started from menu an break our networking connection |
183 | */ | 187 | */ |
184 | if (checkBluezStatus() && !m_wasOn) | 188 | if (checkBluezStatus() && !m_wasOn) |
185 | setBluezStatus(0); | 189 | setBluezStatus(0); |
186 | doListDevice = false; | 190 | doListDevice = false; |
187 | } | 191 | } |
188 | else if ( str == "listDevices()") { | 192 | else if ( str == "listDevices()") { |
189 | if (checkBluezStatus()) { | 193 | if (checkBluezStatus()) { |
190 | doListDevice = false; | 194 | doListDevice = false; |
191 | timerEvent(0); | 195 | timerEvent(0); |
192 | if (!btManager) { | 196 | if (!btManager) { |
193 | btManager = new Manager("hci0"); | 197 | btManager = new Manager("hci0"); |
194 | connect( btManager, | 198 | connect( btManager, |
195 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), | 199 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), |
196 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; | 200 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; |
197 | } | 201 | } |
198 | btManager->searchDevices(); | 202 | btManager->searchDevices(); |
199 | isScanning = true; | 203 | isScanning = true; |
200 | } else | 204 | } else |
201 | doListDevice = true; | 205 | doListDevice = true; |