summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/applet/bluezapplet.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/applet/bluezapplet.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index f7774f0..127b0af 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -74,22 +74,24 @@ 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 81
81 // 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.
82 QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); 83 QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
83 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), 84 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
84 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); 85 this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
85 ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); 86 ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
86 } 87 }
87 88
88 BluezApplet::~BluezApplet() { 89 BluezApplet::~BluezApplet() {
89 if ( btDevice ) { 90 if ( btDevice ) {
91 ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
90 delete btDevice; 92 delete btDevice;
91 } 93 }
92 if ( btManager ) { 94 if ( btManager ) {
93 delete btManager; 95 delete btManager;
94 } 96 }
95 } 97 }
@@ -124,28 +126,26 @@ namespace OpieTooth {
124 break; 126 break;
125 127
126 case Model_iPAQ_H5xxx: 128 case Model_iPAQ_H5xxx:
127 btDevice = new Device( "/dev/tts/1", "any", "921600" ); 129 btDevice = new Device( "/dev/tts/1", "any", "921600" );
128 break; 130 break;
129 131
130#ifndef OPIE120 132#if OPIE_VERSION >= 102010
131 case Model_MyPal_716: 133 case Model_MyPal_716:
132 btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); 134 btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" );
133 break; 135 break;
134#endif 136#endif
135 137
136 default: 138 default:
137 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); 139 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
138 break; 140 break;
139 } 141 }
140 if (sync) { 142 m_sync = sync;
141 ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); 143 connect(btDevice, SIGNAL(device(const QString&, bool)),
142 } else { 144 this, SLOT(slotDevice(const QString&, bool)));
143 QCopEnvelope e("QPE/System", "execute(QString)"); 145
144 e << QString("/etc/init.d/bluetooth start");
145 }
146 } else { 146 } else {
147 ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); 147 ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
148 if ( btManager ) { 148 if ( btManager ) {
149 delete btManager; 149 delete btManager;
150 btManager = 0; 150 btManager = 0;
151 } 151 }
@@ -333,11 +333,28 @@ namespace OpieTooth {
333 } 333 }
334 334
335 if (bluezDiscoveryActive) { 335 if (bluezDiscoveryActive) {
336 p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); 336 p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap );
337 } 337 }
338 } 338 }
339 /**
340 * Reacts on device up
341 * @param name device name
342 * @param up if device was brought up
343 */
344 void BluezApplet::slotDevice(const QString& name, bool up)
345 {
346 if (!up)
347 return;
348 odebug << name << " is up" << oendl;
349 if (m_sync) {
350 ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
351 } else {
352 QCopEnvelope e("QPE/System", "execute(QString)");
353 e << QString("/etc/init.d/bluetooth start");
354 }
355 }
339}; 356};
340 357
341 358
342EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet ) 359EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet )
343 360