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
@@ -16,24 +16,26 @@
16#include "irda.h" 16#include "irda.h"
17#include <qapplication.h> 17#include <qapplication.h>
18#include <stdlib.h> 18#include <stdlib.h>
19 19
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>
36#include <qslider.h> 38#include <qslider.h>
37#include <qlayout.h> 39#include <qlayout.h>
38#include <qframe.h> 40#include <qframe.h>
39#include <qpixmap.h> 41#include <qpixmap.h>
@@ -140,51 +142,60 @@ void IrdaApplet::mousePressEvent( QMouseEvent *)
140 142
141 //menu->insertItem( tr("More..."), 4 ); 143 //menu->insertItem( tr("More..."), 4 );
142 if (irdaactive) 144 if (irdaactive)
143 menu->insertItem( tr("Disable IrDA"), 0 ); 145 menu->insertItem( tr("Disable IrDA"), 0 );
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:
163 setIrdaStatus(1); 168 setIrdaStatus(1);
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();
187 irdaDiscoveryActive = checkIrdaDiscoveryStatus(); 198 irdaDiscoveryActive = checkIrdaDiscoveryStatus();
188 199
189 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery)) 200 if ((irdaactive != oldactive) || (irdaDiscoveryActive != olddiscovery))
190 paintEvent(NULL); 201 paintEvent(NULL);
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
@@ -3,60 +3,59 @@
3** All rights reserved. 3** All rights reserved.
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
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>
25#include <qfile.h> 25#include <qfile.h>
26 26
27 27
28class IrdaApplet : public QWidget 28class IrdaApplet : public QWidget
29{ 29{
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
61#endif // __SCREENSHOT_APPLET_H__ 60#endif // __SCREENSHOT_APPLET_H__
62 61