summaryrefslogtreecommitdiff
authorerik <erik>2007-03-06 01:24:35 (UTC)
committer erik <erik>2007-03-06 01:24:35 (UTC)
commit3efe70df6fdaf32a8213ceadbdd1679a0a658934 (patch) (side-by-side diff)
treef5f2459bd9435602d43438ae4aca39d9f51927ea
parent6b0fa616c4aac654c549621eb0009ab3eb32fe34 (diff)
downloadopie-3efe70df6fdaf32a8213ceadbdd1679a0a658934.zip
opie-3efe70df6fdaf32a8213ceadbdd1679a0a658934.tar.gz
opie-3efe70df6fdaf32a8213ceadbdd1679a0a658934.tar.bz2
Bluetooth didn't quite work for kernel 2.6 based iPAQs in familiar. This
patch fixes that by reading the distro supplied file in /etc/sysconfig. This patch was submitted by Slavek Banko. Thank you Slavek!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 787abc6..60fa4f8 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -7,168 +7,189 @@
:=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; version 2 of the License.
     ._= =}       :
    .%+i>       _;_.
    .i_,=:_.      -<s. This library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
  --        :-= this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "bluezapplet.h"
/* OPIE */
#include <opie2/otaskbarapplet.h>
#include <opie2/odevice.h>
#include <opie2/odebug.h>
#include <opie2/oresource.h>
#include <opie2/oprocess.h>
#include <qpe/version.h>
#include <qpe/applnk.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
using namespace Opie::Core;
/* QT */
#include <qapplication.h>
#include <qpoint.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qtimer.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
+#include <qfile.h>
+#include <qtextstream.h>
/* STD */
#include <device.h>
namespace OpieTooth {
BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
setFixedHeight( AppLnk::smallIconSize() );
setFixedWidth( AppLnk::smallIconSize() );
#if OPIE_VERSION < 102010
bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" );
bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" );
bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" );
bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" );
#else
bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon );
bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon );
bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon );
bluezReceiveOnPixmap = OResource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon );
#endif
startTimer(2000);
btDevice = 0;
btManager = 0;
bluezactive = false;
bluezDiscoveryActive = false;
bluezReceiveActive = false;
bluezReceiveChanged = false;
doListDevice = false;
isScanning = false;
m_wasOn = false;
m_sync = false;
// TODO: determine whether this channel has to be closed at destruction time.
QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
}
BluezApplet::~BluezApplet() {
if ( btDevice ) {
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
delete btDevice;
}
if ( btManager ) {
delete btManager;
}
}
int BluezApplet::position()
{
return 6;
}
bool BluezApplet::checkBluezStatus() {
if (btDevice) {
if (btDevice->isLoaded() ) {
odebug << "btDevice isLoaded" << oendl;
return true;
} else {
odebug << "btDevice is NOT loaded" << oendl;
return false;
}
} else {
odebug << "btDevice is ZERO" << oendl;
return false;
}
}
int BluezApplet::setBluezStatus(int c, bool sync) {
if ( c == 1 ) {
+ QFile cfg("/etc/sysconfig/bluetooth");
+ if ( cfg.open( IO_ReadOnly ) ) {
+ QTextStream stream( &cfg );
+ QString streamIn = stream.read();
+ QStringList list = QStringList::split( "\n", streamIn );
+ cfg.close();
+ if ( list.grep( "BLUETOOTH_PORT=" ).count() > 0 &&
+ list.grep( "BLUETOOTH_PROTOCOL=" ).count() > 0 &&
+ list.grep( "BLUETOOTH_SPEED=" ).count() > 0)
+ {
+ btDevice =
+ new Device( list.grep( "BLUETOOTH_PORT=" )[0].replace( QString( "BLUETOOTH_PORT=" ), ""),
+ list.grep( "BLUETOOTH_PROTOCOL=" )[0].replace( QString( "BLUETOOTH_PROTOCOL=" ), ""),
+ list.grep( "BLUETOOTH_SPEED=" )[0].replace( QString( "BLUETOOTH_SPEED=" ), "" ) );
+ return 0;
+ }
+ }
+
+ // Device-specific stuff - should be removed
switch ( ODevice::inst()->model() ) {
case Model_iPAQ_H39xx:
btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
break;
case Model_iPAQ_H5xxx:
btDevice = new Device( "/dev/tts/1", "any", "921600" );
break;
#if OPIE_VERSION >= 102010
case Model_MyPal_716:
btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" );
break;
#endif
case Model_HTC_Universal:
btDevice = new Device( "/dev/ttyS1", "texas", "115200" );
break;
case Model_iPAQ_H22xx:
btDevice = new Device( "/dev/tts/3", "any", "921600" );
break;
default:
btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
break;
}
m_sync = sync;
connect(btDevice, SIGNAL(device(const QString&, bool)),
this, SLOT(slotDevice(const QString&, bool)));
} else {
setObexRecieveStatus(0);
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
if ( btManager ) {
delete btManager;
btManager = 0;
}
if ( btDevice ) {
delete btDevice;
btDevice = 0;
}
}
return 0;
}
int BluezApplet::checkBluezDiscoveryStatus() {
return isScanning;
}