-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 21 |
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 | |||
@@ -31,48 +31,50 @@ | |||
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/otaskbarapplet.h> | 33 | #include <opie2/otaskbarapplet.h> |
34 | #include <opie2/odevice.h> | 34 | #include <opie2/odevice.h> |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | #include <opie2/oresource.h> | 36 | #include <opie2/oresource.h> |
37 | #include <opie2/oprocess.h> | 37 | #include <opie2/oprocess.h> |
38 | #include <qpe/version.h> | 38 | #include <qpe/version.h> |
39 | #include <qpe/applnk.h> | 39 | #include <qpe/applnk.h> |
40 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | using namespace Opie::Core; | 42 | using namespace Opie::Core; |
43 | 43 | ||
44 | /* QT */ | 44 | /* QT */ |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qpoint.h> | 46 | #include <qpoint.h> |
47 | #include <qpainter.h> | 47 | #include <qpainter.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qframe.h> | 49 | #include <qframe.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qstring.h> | 51 | #include <qstring.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
55 | #include <qfile.h> | ||
56 | #include <qtextstream.h> | ||
55 | 57 | ||
56 | /* STD */ | 58 | /* STD */ |
57 | #include <device.h> | 59 | #include <device.h> |
58 | 60 | ||
59 | namespace OpieTooth { | 61 | namespace OpieTooth { |
60 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | 62 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { |
61 | setFixedHeight( AppLnk::smallIconSize() ); | 63 | setFixedHeight( AppLnk::smallIconSize() ); |
62 | setFixedWidth( AppLnk::smallIconSize() ); | 64 | setFixedWidth( AppLnk::smallIconSize() ); |
63 | #if OPIE_VERSION < 102010 | 65 | #if OPIE_VERSION < 102010 |
64 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 66 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
65 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 67 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
66 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); | 68 | bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass.png" ); |
67 | bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" ); | 69 | bluezReceiveOnPixmap = Resource::loadPixmap( "bluetoothapplet/receive.png" ); |
68 | #else | 70 | #else |
69 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); | 71 | bluezOnPixmap = OResource::loadImage( "bluetoothapplet/bluezon", OResource::SmallIcon ); |
70 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); | 72 | bluezOffPixmap = OResource::loadImage( "bluetoothapplet/bluezoff", Opie::Core::OResource::SmallIcon ); |
71 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); | 73 | bluezDiscoveryOnPixmap = OResource::loadImage( "bluetoothapplet/bluezondiscovery", Opie::Core::OResource::SmallIcon ); |
72 | bluezReceiveOnPixmap = OResource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon ); | 74 | bluezReceiveOnPixmap = OResource::loadImage( "bluetoothapplet/bluezonreceive", Opie::Core::OResource::SmallIcon ); |
73 | #endif | 75 | #endif |
74 | startTimer(2000); | 76 | startTimer(2000); |
75 | btDevice = 0; | 77 | btDevice = 0; |
76 | btManager = 0; | 78 | btManager = 0; |
77 | bluezactive = false; | 79 | bluezactive = false; |
78 | bluezDiscoveryActive = false; | 80 | bluezDiscoveryActive = false; |
@@ -103,48 +105,67 @@ namespace OpieTooth { | |||
103 | int BluezApplet::position() | 105 | int BluezApplet::position() |
104 | { | 106 | { |
105 | return 6; | 107 | return 6; |
106 | } | 108 | } |
107 | 109 | ||
108 | 110 | ||
109 | bool BluezApplet::checkBluezStatus() { | 111 | bool BluezApplet::checkBluezStatus() { |
110 | if (btDevice) { | 112 | if (btDevice) { |
111 | if (btDevice->isLoaded() ) { | 113 | if (btDevice->isLoaded() ) { |
112 | odebug << "btDevice isLoaded" << oendl; | 114 | odebug << "btDevice isLoaded" << oendl; |
113 | return true; | 115 | return true; |
114 | } else { | 116 | } else { |
115 | odebug << "btDevice is NOT loaded" << oendl; | 117 | odebug << "btDevice is NOT loaded" << oendl; |
116 | return false; | 118 | return false; |
117 | } | 119 | } |
118 | } else { | 120 | } else { |
119 | odebug << "btDevice is ZERO" << oendl; | 121 | odebug << "btDevice is ZERO" << oendl; |
120 | return false; | 122 | return false; |
121 | } | 123 | } |
122 | } | 124 | } |
123 | 125 | ||
124 | int BluezApplet::setBluezStatus(int c, bool sync) { | 126 | int BluezApplet::setBluezStatus(int c, bool sync) { |
125 | 127 | ||
126 | if ( c == 1 ) { | 128 | if ( c == 1 ) { |
129 | QFile cfg("/etc/sysconfig/bluetooth"); | ||
130 | if ( cfg.open( IO_ReadOnly ) ) { | ||
131 | QTextStream stream( &cfg ); | ||
132 | QString streamIn = stream.read(); | ||
133 | QStringList list = QStringList::split( "\n", streamIn ); | ||
134 | cfg.close(); | ||
135 | if ( list.grep( "BLUETOOTH_PORT=" ).count() > 0 && | ||
136 | list.grep( "BLUETOOTH_PROTOCOL=" ).count() > 0 && | ||
137 | list.grep( "BLUETOOTH_SPEED=" ).count() > 0) | ||
138 | { | ||
139 | btDevice = | ||
140 | new Device( list.grep( "BLUETOOTH_PORT=" )[0].replace( QString( "BLUETOOTH_PORT=" ), ""), | ||
141 | list.grep( "BLUETOOTH_PROTOCOL=" )[0].replace( QString( "BLUETOOTH_PROTOCOL=" ), ""), | ||
142 | list.grep( "BLUETOOTH_SPEED=" )[0].replace( QString( "BLUETOOTH_SPEED=" ), "" ) ); | ||
143 | return 0; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | // Device-specific stuff - should be removed | ||
127 | switch ( ODevice::inst()->model() ) { | 148 | switch ( ODevice::inst()->model() ) { |
128 | case Model_iPAQ_H39xx: | 149 | case Model_iPAQ_H39xx: |
129 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 150 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
130 | break; | 151 | break; |
131 | 152 | ||
132 | case Model_iPAQ_H5xxx: | 153 | case Model_iPAQ_H5xxx: |
133 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 154 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
134 | break; | 155 | break; |
135 | 156 | ||
136 | #if OPIE_VERSION >= 102010 | 157 | #if OPIE_VERSION >= 102010 |
137 | case Model_MyPal_716: | 158 | case Model_MyPal_716: |
138 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 159 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
139 | break; | 160 | break; |
140 | #endif | 161 | #endif |
141 | case Model_HTC_Universal: | 162 | case Model_HTC_Universal: |
142 | btDevice = new Device( "/dev/ttyS1", "texas", "115200" ); | 163 | btDevice = new Device( "/dev/ttyS1", "texas", "115200" ); |
143 | break; | 164 | break; |
144 | 165 | ||
145 | case Model_iPAQ_H22xx: | 166 | case Model_iPAQ_H22xx: |
146 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); | 167 | btDevice = new Device( "/dev/tts/3", "any", "921600" ); |
147 | break; | 168 | break; |
148 | 169 | ||
149 | default: | 170 | default: |
150 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 171 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |