author | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
commit | 5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f (patch) (unidiff) | |
tree | e9ea63a2fe15982e98886af727649dc6a513faac /noncore/net/opietooth/applet | |
parent | 620d55ae3b94fa8d2fa696b6626893e4520c3a02 (diff) | |
download | opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.zip opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.gz opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.bz2 |
OBEX push functionality moved to libbluetooth1.
Made some reformatting in device.cc
In bluezapplet.cpp /etc/init.d/bluetooth is started synchronously if it's called from QCopMessage.
Diffstat (limited to 'noncore/net/opietooth/applet') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 12 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 90b0c6d..6351d4e 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -95,102 +95,106 @@ namespace OpieTooth { | |||
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | int BluezApplet::position() | 98 | int BluezApplet::position() |
99 | { | 99 | { |
100 | return 6; | 100 | return 6; |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | bool BluezApplet::checkBluezStatus() { | 104 | bool BluezApplet::checkBluezStatus() { |
105 | if (btDevice) { | 105 | if (btDevice) { |
106 | if (btDevice->isLoaded() ) { | 106 | if (btDevice->isLoaded() ) { |
107 | odebug << "btDevice isLoaded" << oendl; | 107 | odebug << "btDevice isLoaded" << oendl; |
108 | return true; | 108 | return true; |
109 | } else { | 109 | } else { |
110 | odebug << "btDevice is NOT loaded" << oendl; | 110 | odebug << "btDevice is NOT loaded" << oendl; |
111 | return false; | 111 | return false; |
112 | } | 112 | } |
113 | } else { | 113 | } else { |
114 | odebug << "btDevice is ZERO" << oendl; | 114 | odebug << "btDevice is ZERO" << oendl; |
115 | return false; | 115 | return false; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | int BluezApplet::setBluezStatus(int c) { | 119 | int BluezApplet::setBluezStatus(int c, bool sync) { |
120 | 120 | ||
121 | if ( c == 1 ) { | 121 | if ( c == 1 ) { |
122 | switch ( ODevice::inst()->model() ) { | 122 | switch ( ODevice::inst()->model() ) { |
123 | case Model_iPAQ_H39xx: | 123 | case Model_iPAQ_H39xx: |
124 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 124 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
125 | break; | 125 | break; |
126 | 126 | ||
127 | case Model_iPAQ_H5xxx: | 127 | case Model_iPAQ_H5xxx: |
128 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 128 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
129 | break; | 129 | break; |
130 | 130 | ||
131 | #ifndef OPIE120 | 131 | #ifndef OPIE120 |
132 | case Model_MyPal_716: | 132 | case Model_MyPal_716: |
133 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 133 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
134 | break; | 134 | break; |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | default: | 137 | default: |
138 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 138 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | QCopEnvelope e("QPE/System", "execute(QString)"); | 141 | if (sync) { |
142 | e << QString("/etc/init.d/bluetooth start"); | 142 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); |
143 | } else { | ||
144 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
145 | e << QString("/etc/init.d/bluetooth start"); | ||
146 | } | ||
143 | } else { | 147 | } else { |
144 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 148 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
145 | if ( btManager ) { | 149 | if ( btManager ) { |
146 | delete btManager; | 150 | delete btManager; |
147 | btManager = 0; | 151 | btManager = 0; |
148 | } | 152 | } |
149 | if ( btDevice ) { | 153 | if ( btDevice ) { |
150 | delete btDevice; | 154 | delete btDevice; |
151 | btDevice = 0; | 155 | btDevice = 0; |
152 | } | 156 | } |
153 | } | 157 | } |
154 | return 0; | 158 | return 0; |
155 | } | 159 | } |
156 | 160 | ||
157 | int BluezApplet::checkBluezDiscoveryStatus() { | 161 | int BluezApplet::checkBluezDiscoveryStatus() { |
158 | return isScanning; | 162 | return isScanning; |
159 | } | 163 | } |
160 | 164 | ||
161 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 165 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
162 | return bluezDiscoveryActive = d; | 166 | return bluezDiscoveryActive = d; |
163 | } | 167 | } |
164 | 168 | ||
165 | // FIXME mbhaynie | 169 | // FIXME mbhaynie |
166 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 170 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
167 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 171 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
168 | { | 172 | { |
169 | if ( str == "enableBluetooth()") { | 173 | if ( str == "enableBluetooth()") { |
170 | m_wasOn = checkBluezStatus(); | 174 | m_wasOn = checkBluezStatus(); |
171 | if (!m_wasOn) { | 175 | if (!m_wasOn) { |
172 | setBluezStatus(1); | 176 | setBluezStatus(1, true); |
173 | sleep(2); | 177 | sleep(2); |
174 | } | 178 | } |
175 | } | 179 | } |
176 | else if ( str == "disableBluetooth()") { | 180 | else if ( str == "disableBluetooth()") { |
177 | /* | 181 | /* |
178 | * We can down BT only if it was started by qcop. We don't want | 182 | * We can down BT only if it was started by qcop. We don't want |
179 | * to down BT started from menu an break our networking connection | 183 | * to down BT started from menu an break our networking connection |
180 | */ | 184 | */ |
181 | if (checkBluezStatus() && !m_wasOn) | 185 | if (checkBluezStatus() && !m_wasOn) |
182 | setBluezStatus(0); | 186 | setBluezStatus(0); |
183 | doListDevice = false; | 187 | doListDevice = false; |
184 | } | 188 | } |
185 | else if ( str == "listDevices()") { | 189 | else if ( str == "listDevices()") { |
186 | if (checkBluezStatus()) { | 190 | if (checkBluezStatus()) { |
187 | doListDevice = false; | 191 | doListDevice = false; |
188 | timerEvent(0); | 192 | timerEvent(0); |
189 | if (!btManager) { | 193 | if (!btManager) { |
190 | btManager = new Manager("hci0"); | 194 | btManager = new Manager("hci0"); |
191 | connect( btManager, | 195 | connect( btManager, |
192 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), | 196 | SIGNAL( foundDevices(const QString&, RemoteDevice::ValueList) ), |
193 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; | 197 | this, SLOT( fillList(const QString&, RemoteDevice::ValueList) ) ) ; |
194 | } | 198 | } |
195 | btManager->searchDevices(); | 199 | btManager->searchDevices(); |
196 | isScanning = true; | 200 | isScanning = true; |
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h index 90bee3b..1937934 100644 --- a/noncore/net/opietooth/applet/bluezapplet.h +++ b/noncore/net/opietooth/applet/bluezapplet.h | |||
@@ -34,48 +34,48 @@ | |||
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <manager.h> | 35 | #include <manager.h> |
36 | #include <opie2/oprocess.h> | 36 | #include <opie2/oprocess.h> |
37 | 37 | ||
38 | namespace OpieTooth { | 38 | namespace OpieTooth { |
39 | class Device; | 39 | class Device; |
40 | 40 | ||
41 | class BluezApplet : public QWidget { | 41 | class BluezApplet : public QWidget { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | BluezApplet( QWidget *parent = 0, const char *name=0 ); | 44 | BluezApplet( QWidget *parent = 0, const char *name=0 ); |
45 | ~BluezApplet(); | 45 | ~BluezApplet(); |
46 | static int position(); | 46 | static int position(); |
47 | protected: | 47 | protected: |
48 | void timerEvent(QTimerEvent *te ); | 48 | void timerEvent(QTimerEvent *te ); |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void fillList( const QString& device, RemoteDevice::ValueList list ); | 51 | void fillList( const QString& device, RemoteDevice::ValueList list ); |
52 | 52 | ||
53 | private: | 53 | private: |
54 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
55 | void paintEvent( QPaintEvent* ); | 55 | void paintEvent( QPaintEvent* ); |
56 | void launchManager(); | 56 | void launchManager(); |
57 | bool checkBluezStatus(); | 57 | bool checkBluezStatus(); |
58 | int setBluezStatus(int); | 58 | int setBluezStatus(int, bool sync = false); |
59 | int checkBluezDiscoveryStatus(); | 59 | int checkBluezDiscoveryStatus(); |
60 | int setBluezDiscoveryStatus(int); | 60 | int setBluezDiscoveryStatus(int); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | Device* btDevice; | 63 | Device* btDevice; |
64 | Manager *btManager; | 64 | Manager *btManager; |
65 | QPixmap bluezOnPixmap; | 65 | QPixmap bluezOnPixmap; |
66 | QPixmap bluezOffPixmap; | 66 | QPixmap bluezOffPixmap; |
67 | QPixmap bluezDiscoveryOnPixmap; | 67 | QPixmap bluezDiscoveryOnPixmap; |
68 | bool bluezactive; | 68 | bool bluezactive; |
69 | bool bluezDiscoveryActive; | 69 | bool bluezDiscoveryActive; |
70 | bool doListDevice; //If I have to list devices after bringing BT up? | 70 | bool doListDevice; //If I have to list devices after bringing BT up? |
71 | bool isScanning; //If I'm scanning devices | 71 | bool isScanning; //If I'm scanning devices |
72 | bool m_wasOn; //If BT was started by menu? | 72 | bool m_wasOn; //If BT was started by menu? |
73 | 73 | ||
74 | private slots: | 74 | private slots: |
75 | void slotMessage( const QCString& , const QByteArray& ); | 75 | void slotMessage( const QCString& , const QByteArray& ); |
76 | }; | 76 | }; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | #endif | 80 | #endif |
81 | 81 | ||