summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-12 15:59:45 (UTC)
committer zecke <zecke>2002-06-12 15:59:45 (UTC)
commit9b87f7a2f2de6b5c1bad4f35f76fc7a0fd1ad021 (patch) (unidiff)
tree3e1ccaae54d96ae3cbb25fba48814fb31c15105d
parent8a53908265672bd3feee0ace40f9e5e38de2f30e (diff)
downloadopie-9b87f7a2f2de6b5c1bad4f35f76fc7a0fd1ad021.zip
opie-9b87f7a2f2de6b5c1bad4f35f76fc7a0fd1ad021.tar.gz
opie-9b87f7a2f2de6b5c1bad4f35f76fc7a0fd1ad021.tar.bz2
Fix memleak and add OBEX receive support
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp21
-rw-r--r--core/applets/irdaapplet/irda.h7
2 files changed, 19 insertions, 9 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index a197957..67e7f22 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -20,16 +20,18 @@
20 20
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qpe/timestring.h> 23#include <qpe/timestring.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/applnk.h> 26#include <qpe/applnk.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/ir.h>
29#include <qpe/qcopenvelope_qws.h>
28 30
29#include <qdir.h> 31#include <qdir.h>
30#include <qfileinfo.h> 32#include <qfileinfo.h>
31#include <qpoint.h> 33#include <qpoint.h>
32#include <qpushbutton.h> 34#include <qpushbutton.h>
33#include <qpainter.h> 35#include <qpainter.h>
34#include <qcombobox.h> 36#include <qcombobox.h>
35#include <qspinbox.h> 37#include <qspinbox.h>
@@ -144,19 +146,22 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
144 else 146 else
145 menu->insertItem( tr("Enable IrDA"), 1 ); 147 menu->insertItem( tr("Enable IrDA"), 1 );
146 148
147 if (irdaDiscoveryActive) 149 if (irdaDiscoveryActive)
148 menu->insertItem( tr("Disable Discovery"), 2 ); 150 menu->insertItem( tr("Disable Discovery"), 2 );
149 else 151 else
150 menu->insertItem( tr("Enable Discovery"), 3 ); 152 menu->insertItem( tr("Enable Discovery"), 3 );
151 153
152 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); 154 if( Ir::supported() ){
155 menu->insertItem( tr("Enable Receive"), 4 );
156 }
157 QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) );
153 ret = menu->exec(p, 2); 158 ret = menu->exec(p, 2);
154 159
155 qDebug("ret was %d\n", ret); 160 qDebug("ret was %d\n", ret);
156 161
157 switch(ret) { 162 switch(ret) {
158 case 0: 163 case 0:
159 setIrdaStatus(0); 164 setIrdaStatus(0);
160 timerEvent(NULL); 165 timerEvent(NULL);
161 break; 166 break;
162 case 1: 167 case 1:
@@ -164,23 +169,29 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
164 timerEvent(NULL); 169 timerEvent(NULL);
165 break; 170 break;
166 case 2: 171 case 2:
167 setIrdaDiscoveryStatus(0); 172 setIrdaDiscoveryStatus(0);
168 timerEvent(NULL); 173 timerEvent(NULL);
169 break; 174 break;
170 case 3: 175 case 3:
171 setIrdaDiscoveryStatus(1); 176 setIrdaDiscoveryStatus(1);
172 timerEvent(NULL); 177 timerEvent(NULL); // NULL is undefined in c++ use 0 or 0l
173 break; 178 break;
174 case 4: 179 case 4: { // enable receive{
180 qWarning("Enable receive" );
181 QCopEnvelope e("QPE/Obex", "receive(bool)" );
182 e << true;
183 break;
184 }
185 case 6:
175 qDebug("FIXME: Bring up pretty menu...\n"); 186 qDebug("FIXME: Bring up pretty menu...\n");
176 // With table of currently-detected devices. 187 // With table of currently-detected devices.
177 } 188 }
178 189 delete menu; // Can somebody explain why use a QPopupMenu* and not QPopupMenu nor QAction. with out delete we will leak cause QPopupMenu doesn't have a parent in this case
179} 190}
180 191
181void IrdaApplet::timerEvent( QTimerEvent * ) 192void IrdaApplet::timerEvent( QTimerEvent * )
182{ 193{
183 int oldactive = irdaactive; 194 int oldactive = irdaactive;
184 int olddiscovery = irdaDiscoveryActive; 195 int olddiscovery = irdaDiscoveryActive;
185 196
186 irdaactive = checkIrdaStatus(); 197 irdaactive = checkIrdaStatus();
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index 2f84909..bb174e8 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -7,18 +7,18 @@
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#ifndef __SCREENSHOT_APPLET_H__ 15#ifndef SCREENSHOT_APPLET_H__
16#define __SCREENSHOT_APPLET_H__ 16#define SCREENSHOT_APPLET_H__
17 17
18 18
19 19
20#include <qwidget.h> 20#include <qwidget.h>
21#include <qframe.h> 21#include <qframe.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23#include <qguardedptr.h> 23#include <qguardedptr.h>
24#include <qtimer.h> 24#include <qtimer.h>
@@ -30,31 +30,30 @@ class IrdaApplet : public QWidget
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 IrdaApplet( QWidget *parent = 0, const char *name=0 ); 32 IrdaApplet( QWidget *parent = 0, const char *name=0 );
33 ~IrdaApplet(); 33 ~IrdaApplet();
34 34
35protected: 35protected:
36 void timerEvent(QTimerEvent *te ); 36 void timerEvent(QTimerEvent *te );
37 37
38public slots:
39private: 38private:
40 void mousePressEvent( QMouseEvent * ); 39 void mousePressEvent( QMouseEvent * );
41 void paintEvent( QPaintEvent* ); 40 void paintEvent( QPaintEvent* );
42 int checkIrdaStatus(); 41 int checkIrdaStatus();
43 int setIrdaStatus(int); 42 int setIrdaStatus(int);
44 int checkIrdaDiscoveryStatus(); 43 int checkIrdaDiscoveryStatus();
45 int setIrdaDiscoveryStatus(int); 44 int setIrdaDiscoveryStatus(int);
46 int sockfd; 45 int sockfd;
47 46
48private: 47private:
49 QPixmap irdaOnPixmap; 48 QPixmap irdaOnPixmap;
50 QPixmap irdaOffPixmap; 49 QPixmap irdaOffPixmap;
51 QPixmap irdaDiscoveryOnPixmap; 50 QPixmap irdaDiscoveryOnPixmap;
52 int irdaactive; 51 int irdaactive; // bool and bitfields later bool irdaactive :1 ;
53 int irdaDiscoveryActive; 52 int irdaDiscoveryActive;
54 53
55private slots: 54private slots:
56 55
57 56
58}; 57};
59 58
60 59