summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2003-02-16 10:01:34 (UTC)
committer zecke <zecke>2003-02-16 10:01:34 (UTC)
commitf1737ebd1afc35528c2452f6a281039c39a28f1f (patch) (unidiff)
tree4172f2e55f7986c52562bf152b0379ede66712a4 /core
parent68675728278f9d47b200e6dd635d3bc1f524b5bf (diff)
downloadopie-f1737ebd1afc35528c2452f6a281039c39a28f1f.zip
opie-f1737ebd1afc35528c2452f6a281039c39a28f1f.tar.gz
opie-f1737ebd1afc35528c2452f6a281039c39a28f1f.tar.bz2
Add some QCOP methods for the new OBEX dialog
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp76
-rw-r--r--core/applets/irdaapplet/irda.h17
2 files changed, 65 insertions, 28 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index c3ddff2..84c656f 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -4,2 +4,3 @@
4** Robert Griebl <sandman@handhelds.org> 4** Robert Griebl <sandman@handhelds.org>
5** Holger Freyther <zecke@handhelds.org> QCOP Interface
5** 6**
@@ -15,2 +16,4 @@
15 16
17#include <qcopchannel_qws.h>
18
16#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
@@ -43,5 +46,5 @@ IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
43 setFixedWidth ( 14 ); 46 setFixedWidth ( 14 );
44 47
45 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); 48 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP );
46 49
47 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); 50 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" );
@@ -50,3 +53,3 @@ IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
50 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); 53 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" );
51 54
52 m_irda_active = false; 55 m_irda_active = false;
@@ -56,2 +59,7 @@ IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
56 m_popup = 0; 59 m_popup = 0;
60 m_wasOn = false;
61
62 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
63 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
64 this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) );
57} 65}
@@ -72,3 +80,3 @@ void IrdaApplet::popup ( QString message, QString icon )
72{ 80{
73 if ( !m_popup ) 81 if ( !m_popup )
74 m_popup = new QPopupMenu ( this ); 82 m_popup = new QPopupMenu ( this );
@@ -76,6 +84,6 @@ void IrdaApplet::popup ( QString message, QString icon )
76 m_popup-> clear ( ); 84 m_popup-> clear ( );
77 85
78 if ( icon. isEmpty ( )) 86 if ( icon. isEmpty ( ))
79 m_popup-> insertItem ( message, 0 ); 87 m_popup-> insertItem ( message, 0 );
80 else 88 else
81 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); 89 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 );
@@ -149,3 +157,3 @@ bool IrdaApplet::setIrdaDiscoveryStatus ( bool d )
149 if ( discovery. open ( IO_WriteOnly | IO_Raw )) { 157 if ( discovery. open ( IO_WriteOnly | IO_Raw )) {
150 discovery.putch ( d ? '1' : '0' ); 158 discovery.putch ( d ? '1' : '0' );
151 return true; 159 return true;
@@ -160,6 +168,6 @@ bool IrdaApplet::setIrdaReceiveStatus ( bool d )
160 e << ( d ? 1 : 0 ); 168 e << ( d ? 1 : 0 );
161 169
162 m_receive_active = d; 170 m_receive_active = d;
163 m_receive_state_changed = true; 171 m_receive_state_changed = true;
164 172
165 return true; 173 return true;
@@ -180,3 +188,3 @@ void IrdaApplet::showDiscovered ( )
180 QString deviceAddr; 188 QString deviceAddr;
181 189
182 // since it is /proc we _must_ use QTextStream 190 // since it is /proc we _must_ use QTextStream
@@ -191,3 +199,3 @@ void IrdaApplet::showDiscovered ( )
191 const QString &line = *lit; 199 const QString &line = *lit;
192 200
193 if ( line. startsWith ( "nickname:" )) { 201 if ( line. startsWith ( "nickname:" )) {
@@ -209,3 +217,3 @@ void IrdaApplet::showDiscovered ( )
209 // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); 217 // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?");
210 218
211 if ( it. data ( ). left ( 3 ) == "+++" ) { 219 if ( it. data ( ). left ( 3 ) == "+++" ) {
@@ -213,3 +221,3 @@ void IrdaApplet::showDiscovered ( )
213 snd_lost. play ( ); 221 snd_lost. play ( );
214 222
215 QMap <QString, QString>::Iterator tmp = it; 223 QMap <QString, QString>::Iterator tmp = it;
@@ -218,3 +226,3 @@ void IrdaApplet::showDiscovered ( )
218 it = tmp; 226 it = tmp;
219 227
220 qcopsend = true; 228 qcopsend = true;
@@ -227,3 +235,3 @@ void IrdaApplet::showDiscovered ( )
227 e << ( m_devices. count ( ) > 0 ); 235 e << ( m_devices. count ( ) > 0 );
228 // } 236 // }
229 } 237 }
@@ -261,3 +269,3 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
261 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); 269 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ));
262 270
263 switch ( menu-> exec ( p )) { 271 switch ( menu-> exec ( p )) {
@@ -276,3 +284,3 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
276 } 284 }
277 285
278 delete menu; 286 delete menu;
@@ -294,6 +302,6 @@ void IrdaApplet::timerEvent ( QTimerEvent * )
294 302
295 if ( m_irda_discovery_active ) 303 if ( m_irda_discovery_active )
296 showDiscovered ( ); 304 showDiscovered ( );
297 305
298 if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) 306 if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate )
299 update ( ); 307 update ( );
@@ -310,4 +318,30 @@ void IrdaApplet::paintEvent ( QPaintEvent * )
310 318
311 if ( m_receive_active ) 319 if ( m_receive_active )
312 p. drawPixmap( 0, 1, m_receiveActivePixmap ); 320 p. drawPixmap( 0, 1, m_receiveActivePixmap );
313} 321}
322/*
323 * We know 3 calls
324 * a) enable
325 * b) disable
326 * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on
327 * c) listDevices: We will return a list of known devices
328 */
329void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) {
330 if ( str == "enableIrda()") {
331 m_wasOn = checkIrdaStatus();
332 if (!m_wasOn)
333 setIrdaStatus( true );
334 }else if ( str == "disableIrda()") {
335 if (!m_wasOn)
336 setIrdaStatus( false );
337 }else if ( str == "listDevices()") {
338 QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)");
339
340 QStringList list;
341 QMap<QString, QString>::Iterator it;
342 for (it = m_devices.begin(); it != m_devices.end(); ++it )
343 list << (*it);
344
345 e << list;
346 }
347}
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index 1b5faa6..675f874 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -26,3 +26,3 @@ class IrdaApplet : public QWidget
26 Q_OBJECT 26 Q_OBJECT
27 27
28public: 28public:
@@ -37,5 +37,6 @@ protected:
37 virtual void paintEvent ( QPaintEvent* ); 37 virtual void paintEvent ( QPaintEvent* );
38 38
39private slots: 39private slots:
40 void popupTimeout ( ); 40 void popupTimeout ( );
41 void slotMessage( const QCString& , const QByteArray& );
41 42
@@ -51,3 +52,3 @@ private:
51 void showDiscovered(); 52 void showDiscovered();
52 53
53private: 54private:
@@ -57,4 +58,4 @@ private:
57 QPixmap m_receiveActivePixmap; 58 QPixmap m_receiveActivePixmap;
58 59
59 bool m_irda_active; 60 bool m_irda_active;
60 bool m_irda_discovery_active; 61 bool m_irda_discovery_active;
@@ -62,3 +63,3 @@ private:
62 bool m_receive_state_changed; 63 bool m_receive_state_changed;
63 64
64 QPopupMenu *m_popup; 65 QPopupMenu *m_popup;
@@ -66,4 +67,6 @@ private:
66 int m_sockfd; 67 int m_sockfd;
67 68
68 QMap <QString, QString> m_devices; 69 QMap <QString, QString> m_devices;
70
71 bool m_wasOn; // if IrDa was enabled
69}; 72};