summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp15
-rw-r--r--core/applets/clipboardapplet/clipboard.h4
-rw-r--r--core/launcher/desktop.cpp6
3 files changed, 22 insertions, 3 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 5848d0f..4fbdf6f 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,233 +1,242 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "clipboard.h" 21#include "clipboard.h"
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qpopupmenu.h> 26#include <qpopupmenu.h>
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qclipboard.h> 29#include <qclipboard.h>
30#include <qtimer.h> 30#include <qtimer.h>
31 31
32//=========================================================================== 32//===========================================================================
33 33
34/* XPM */ 34/* XPM */
35static const char * paste_xpm[] = { 35static const char * paste_xpm[] = {
36"14 16 64 1", 36"14 16 64 1",
37 " c None", 37 " c None",
38 ".c #020202", 38 ".c #020202",
39 "+c #867616", 39 "+c #867616",
40 "@c #A69A42", 40 "@c #A69A42",
41 "#c #BAB676", 41 "#c #BAB676",
42 "$c #060606", 42 "$c #060606",
43 "%c #EAD2AA", 43 "%c #EAD2AA",
44 "&c #F6F6DA", 44 "&c #F6F6DA",
45 "*c #222212", 45 "*c #222212",
46 "=c #86761E", 46 "=c #86761E",
47 "-c #868686", 47 "-c #868686",
48 ";c #5A5202", 48 ";c #5A5202",
49 ">c #8A7E2E", 49 ">c #8A7E2E",
50 ",c #2C2C2C", 50 ",c #2C2C2C",
51 "'c #9A9A9A", 51 "'c #9A9A9A",
52 ")c #F6EADA", 52 ")c #F6EADA",
53 "!c #AAA262", 53 "!c #AAA262",
54 "~c #323232", 54 "~c #323232",
55 "{c #726A32", 55 "{c #726A32",
56 "]c #6E6E6E", 56 "]c #6E6E6E",
57 "^c #C2B69E", 57 "^c #C2B69E",
58 "/c #9E9E9E", 58 "/c #9E9E9E",
59 "(c #EED6BA", 59 "(c #EED6BA",
60 "_c #F2DEC2", 60 "_c #F2DEC2",
61 ":c #D2CE8E", 61 ":c #D2CE8E",
62 "<c #3A3A3A", 62 "<c #3A3A3A",
63 "[c #EACAA2", 63 "[c #EACAA2",
64 "}c #3E3E3E", 64 "}c #3E3E3E",
65 "|c #727272", 65 "|c #727272",
66 "1c #CECECE", 66 "1c #CECECE",
67 "2c #929292", 67 "2c #929292",
68 "3c #4A462A", 68 "3c #4A462A",
69 "4c #424242", 69 "4c #424242",
70 "5c #666666", 70 "5c #666666",
71 "6c #C2AE96", 71 "6c #C2AE96",
72 "7c #767676", 72 "7c #767676",
73 "8c #D6D6D6", 73 "8c #D6D6D6",
74 "9c #C2C2C2", 74 "9c #C2C2C2",
75 "0c #BFA681", 75 "0c #BFA681",
76 "ac #1E1E1E", 76 "ac #1E1E1E",
77 "bc #FAF6F3", 77 "bc #FAF6F3",
78 "cc #AEAEAE", 78 "cc #AEAEAE",
79 "dc #C29A6A", 79 "dc #C29A6A",
80 "ec #FEFEFE", 80 "ec #FEFEFE",
81 "fc #B6B6B6", 81 "fc #B6B6B6",
82 "gc #7E7E7E", 82 "gc #7E7E7E",
83 "hc #FAF2E6", 83 "hc #FAF2E6",
84 "ic #8E8E8E", 84 "ic #8E8E8E",
85 "jc #C6BCAE", 85 "jc #C6BCAE",
86 "kc #DEDEDE", 86 "kc #DEDEDE",
87 "lc #BEBEBE", 87 "lc #BEBEBE",
88 "mc #464646", 88 "mc #464646",
89 "nc #BEAE92", 89 "nc #BEAE92",
90 "oc #262626", 90 "oc #262626",
91 "pc #F2E2CE", 91 "pc #F2E2CE",
92 "qc #C2A175", 92 "qc #C2A175",
93 "rc #CACACA", 93 "rc #CACACA",
94 "sc #969696", 94 "sc #969696",
95 "tc #8A8A8A", 95 "tc #8A8A8A",
96 "uc #828282", 96 "uc #828282",
97 "vc #6A6A6A", 97 "vc #6A6A6A",
98 "wc #BEB6AE", 98 "wc #BEB6AE",
99 "xc #E2E0E0", 99 "xc #E2E0E0",
100 "yc #7A7A7A", 100 "yc #7A7A7A",
101" *{>; ", 101" *{>; ",
102" }}}@e:!;}}} ", 102" }}}@e:!;}}} ",
103"<x8=&:#@+;ll, ", 103"<x8=&:#@+;ll, ",
104"}k/=;;3}337|o ", 104"}k/=;;3}337|o ",
105"<k's24444m45o ", 105"<k's24444m45o ",
106"}8'ss4xkkk]}a ", 106"}8'ss4xkkk]}a ",
107"<1s224keee|b4 ", 107"<1s224keee|b4 ",
108"}r2itmkeee]]44", 108"}r2itmkeee]]44",
109"<9iitmkeeehkw.", 109"<9iitmkeeehkw.",
110"<lt-u4keeb)pn.", 110"<lt-u4keeb)pn.",
111"<fu-umkebhp(0.", 111"<fu-umkebhp(0.",
112"<cugg4kbh)_(q.", 112"<cugg4kbh)_(q.",
113"<cyyymk))p(%q.", 113"<cyyymk))p(%q.",
114",5vvv4k)p_%[q.", 114",5vvv4k)p_%[q.",
115" ...$mljnn0qd.", 115" ...$mljnn0qd.",
116" 4.......,"}; 116" 4.......,"};
117 117
118 118
119ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 119ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
120{ 120{
121 setFixedWidth ( 14 ); 121 setFixedWidth ( 14 );
122 setFixedHeight ( 18 ); 122 setFixedHeight ( 18 );
123 m_clipboardPixmap = QPixmap ( paste_xpm ); 123 m_clipboardPixmap = QPixmap ( paste_xpm );
124 124
125 QTimer *timer = new QTimer ( this ); 125 m_timer = new QTimer ( this );
126 126
127 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); 127 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
128 connect ( timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); 128 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
129 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
129 130
130 timer-> start ( 1000 ); 131 m_timer-> start ( 1500 );
131 132
132 m_menu = 0; 133 m_menu = 0;
133 m_dirty = true; 134 m_dirty = true;
134 m_lasttext = QString::null; 135 m_lasttext = QString::null;
135} 136}
136 137
137ClipboardApplet::~ClipboardApplet ( ) 138ClipboardApplet::~ClipboardApplet ( )
138{ 139{
139} 140}
140 141
142void ClipboardApplet::shutdown ( )
143{
144 // the timer has to be stopped, or Qt/E will hang on quit()
145 // see launcher/desktop.cpp
146
147 m_timer-> stop ( );
148}
149
141void ClipboardApplet::mousePressEvent ( QMouseEvent *) 150void ClipboardApplet::mousePressEvent ( QMouseEvent *)
142{ 151{
143 if ( m_dirty ) { 152 if ( m_dirty ) {
144 delete m_menu; 153 delete m_menu;
145 154
146 m_menu = new QPopupMenu ( this ); 155 m_menu = new QPopupMenu ( this );
147 m_menu-> setCheckable ( true ); 156 m_menu-> setCheckable ( true );
148 157
149 if ( m_history. count ( )) { 158 if ( m_history. count ( )) {
150 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 159 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
151 QString str = m_history [i]; 160 QString str = m_history [i];
152 161
153 if ( str. length ( ) > 20 ) 162 if ( str. length ( ) > 20 )
154 str = str. left ( 20 ) + "..."; 163 str = str. left ( 20 ) + "...";
155 164
156 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 165 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
157 m_menu-> setItemChecked ( i, false ); 166 m_menu-> setItemChecked ( i, false );
158 } 167 }
159 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 168 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
160 m_menu-> insertSeparator ( ); 169 m_menu-> insertSeparator ( );
161 } 170 }
162 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 171 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
163 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 172 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
164 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 173 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
165 174
166 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); 175 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
167 176
168 m_dirty = false; 177 m_dirty = false;
169 } 178 }
170 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 179 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
171 QSize s = m_menu-> sizeHint ( ); 180 QSize s = m_menu-> sizeHint ( );
172 181
173 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 182 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
174} 183}
175 184
176void ClipboardApplet::action(int id) 185void ClipboardApplet::action(int id)
177{ 186{
178 ushort unicode = 0; 187 ushort unicode = 0;
179 int scan = 0; 188 int scan = 0;
180 189
181 switch ( id ) { 190 switch ( id ) {
182 case 100: 191 case 100:
183 unicode = 'X' - '@'; 192 unicode = 'X' - '@';
184 scan = Key_X; // Cut 193 scan = Key_X; // Cut
185 break; 194 break;
186 case 101: 195 case 101:
187 unicode = 'C' - '@'; 196 unicode = 'C' - '@';
188 scan = Key_C; // Copy 197 scan = Key_C; // Copy
189 break; 198 break;
190 case 102: 199 case 102:
191 unicode = 'V' - '@'; 200 unicode = 'V' - '@';
192 scan = Key_V; // Paste 201 scan = Key_V; // Paste
193 break; 202 break;
194 203
195 default: 204 default:
196 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { 205 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
197 QApplication::clipboard ( )-> setText ( m_history [id] ); 206 QApplication::clipboard ( )-> setText ( m_history [id] );
198 207
199 for ( uint i = 0; i < m_history. count ( ); i++ ) 208 for ( uint i = 0; i < m_history. count ( ); i++ )
200 m_menu-> setItemChecked ( i, i == uint( id )); 209 m_menu-> setItemChecked ( i, i == uint( id ));
201 210
202 unicode = 'V' - '@'; 211 unicode = 'V' - '@';
203 scan = Key_V; 212 scan = Key_V;
204 } 213 }
205 break; 214 break;
206 } 215 }
207 216
208 if ( scan ) { 217 if ( scan ) {
209 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); 218 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
210 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); 219 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
211 } 220 }
212} 221}
213 222
214void ClipboardApplet::paintEvent ( QPaintEvent* ) 223void ClipboardApplet::paintEvent ( QPaintEvent* )
215{ 224{
216 QPainter p ( this ); 225 QPainter p ( this );
217 p. drawPixmap ( 0, 1, m_clipboardPixmap ); 226 p. drawPixmap ( 0, 1, m_clipboardPixmap );
218} 227}
219 228
220void ClipboardApplet::newData ( ) 229void ClipboardApplet::newData ( )
221{ 230{
222 QCString type = "plain"; 231 QCString type = "plain";
223 QString txt = QApplication::clipboard ( )-> text ( type ); 232 QString txt = QApplication::clipboard ( )-> text ( type );
224 233
225 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { 234 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
226 m_history. append ( txt ); 235 m_history. append ( txt );
227 236
228 if ( m_history. count ( ) > 5 ) 237 if ( m_history. count ( ) > 5 )
229 m_history. remove ( m_history. begin ( )); 238 m_history. remove ( m_history. begin ( ));
230 239
231 m_dirty = true; 240 m_dirty = true;
232 } 241 }
233} 242}
diff --git a/core/applets/clipboardapplet/clipboard.h b/core/applets/clipboardapplet/clipboard.h
index 84743d9..ec87d39 100644
--- a/core/applets/clipboardapplet/clipboard.h
+++ b/core/applets/clipboardapplet/clipboard.h
@@ -1,53 +1,57 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __CLIPBOARD_APPLET_H__ 20#ifndef __CLIPBOARD_APPLET_H__
21#define __CLIPBOARD_APPLET_H__ 21#define __CLIPBOARD_APPLET_H__
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26 26
27class QTimer;
28
27class ClipboardApplet : public QWidget 29class ClipboardApplet : public QWidget
28{ 30{
29 Q_OBJECT 31 Q_OBJECT
30public: 32public:
31 ClipboardApplet ( QWidget *parent = 0, const char *name=0 ); 33 ClipboardApplet ( QWidget *parent = 0, const char *name=0 );
32 ~ClipboardApplet ( ); 34 ~ClipboardApplet ( );
33 35
34protected: 36protected:
35 void mousePressEvent ( QMouseEvent *); 37 void mousePressEvent ( QMouseEvent *);
36 void paintEvent ( QPaintEvent* ); 38 void paintEvent ( QPaintEvent* );
37 39
38private slots: 40private slots:
39 void action ( int ); 41 void action ( int );
40 void newData ( ); 42 void newData ( );
43 void shutdown ( );
41 44
42private: 45private:
43 QPopupMenu * m_menu; 46 QPopupMenu * m_menu;
44 QStringList m_history; 47 QStringList m_history;
45 bool m_dirty; 48 bool m_dirty;
46 QString m_lasttext; 49 QString m_lasttext;
50 QTimer * m_timer;
47 51
48 QPixmap m_clipboardPixmap; 52 QPixmap m_clipboardPixmap;
49}; 53};
50 54
51 55
52#endif // __CLIPBOARD_APPLET_H__ 56#endif // __CLIPBOARD_APPLET_H__
53 57
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index e58b08c..f90da1a 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,790 +1,796 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "mrulist.h" 24#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/global.h> 40#include <qpe/global.h>
41 41
42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
43#include <qpe/custom.h> 43#include <qpe/custom.h>
44#endif 44#endif
45 45
46#include <opie/odevice.h> 46#include <opie/odevice.h>
47 47
48#include <qgfx_qws.h> 48#include <qgfx_qws.h>
49#include <qmainwindow.h> 49#include <qmainwindow.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qtimer.h> 51#include <qtimer.h>
52#include <qwindowsystem_qws.h> 52#include <qwindowsystem_qws.h>
53 53
54#include <qvaluelist.h> 54#include <qvaluelist.h>
55 55
56#include <stdlib.h> 56#include <stdlib.h>
57#include <unistd.h> 57#include <unistd.h>
58 58
59class QCopKeyRegister 59class QCopKeyRegister
60{ 60{
61public: 61public:
62 QCopKeyRegister() : keyCode(0) { } 62 QCopKeyRegister() : keyCode(0) { }
63 QCopKeyRegister(int k, const QString &c, const QString &m) 63 QCopKeyRegister(int k, const QString &c, const QString &m)
64 : keyCode(k), channel(c), message(m) { } 64 : keyCode(k), channel(c), message(m) { }
65 65
66 int getKeyCode() const { return keyCode; } 66 int getKeyCode() const { return keyCode; }
67 QString getChannel() const { return channel; } 67 QString getChannel() const { return channel; }
68 QString getMessage() const { return message; } 68 QString getMessage() const { return message; }
69 69
70private: 70private:
71 int keyCode; 71 int keyCode;
72 QString channel, message; 72 QString channel, message;
73}; 73};
74 74
75typedef QValueList<QCopKeyRegister> KeyRegisterList; 75typedef QValueList<QCopKeyRegister> KeyRegisterList;
76KeyRegisterList keyRegisterList; 76KeyRegisterList keyRegisterList;
77 77
78static Desktop* qpedesktop = 0; 78static Desktop* qpedesktop = 0;
79static int loggedin=0; 79static int loggedin=0;
80static void login(bool at_poweron) 80static void login(bool at_poweron)
81{ 81{
82 if ( !loggedin ) { 82 if ( !loggedin ) {
83 Global::terminateBuiltin("calibrate"); 83 Global::terminateBuiltin("calibrate");
84 Password::authenticate(at_poweron); 84 Password::authenticate(at_poweron);
85 loggedin=1; 85 loggedin=1;
86 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 86 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
87 } 87 }
88} 88}
89 89
90bool Desktop::screenLocked() 90bool Desktop::screenLocked()
91{ 91{
92 return loggedin == 0; 92 return loggedin == 0;
93} 93}
94 94
95/* 95/*
96 Priority is number of alerts that are needed to pop up 96 Priority is number of alerts that are needed to pop up
97 alert. 97 alert.
98 */ 98 */
99class DesktopPowerAlerter : public QMessageBox 99class DesktopPowerAlerter : public QMessageBox
100{ 100{
101public: 101public:
102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
103 : QMessageBox( tr("Battery Status"), "Low Battery", 103 : QMessageBox( tr("Battery Status"), "Low Battery",
104 QMessageBox::Critical, 104 QMessageBox::Critical,
105 QMessageBox::Ok | QMessageBox::Default, 105 QMessageBox::Ok | QMessageBox::Default,
106 QMessageBox::NoButton, QMessageBox::NoButton, 106 QMessageBox::NoButton, QMessageBox::NoButton,
107 parent, name, FALSE ) 107 parent, name, FALSE )
108 { 108 {
109 currentPriority = INT_MAX; 109 currentPriority = INT_MAX;
110 alertCount = 0; 110 alertCount = 0;
111 } 111 }
112 112
113 void alert( const QString &text, int priority ); 113 void alert( const QString &text, int priority );
114 void hideEvent( QHideEvent * ); 114 void hideEvent( QHideEvent * );
115private: 115private:
116 int currentPriority; 116 int currentPriority;
117 int alertCount; 117 int alertCount;
118}; 118};
119 119
120void DesktopPowerAlerter::alert( const QString &text, int priority ) 120void DesktopPowerAlerter::alert( const QString &text, int priority )
121{ 121{
122 alertCount++; 122 alertCount++;
123 if ( alertCount < priority ) 123 if ( alertCount < priority )
124 return; 124 return;
125 if ( priority > currentPriority ) 125 if ( priority > currentPriority )
126 return; 126 return;
127 currentPriority = priority; 127 currentPriority = priority;
128 setText( text ); 128 setText( text );
129 show(); 129 show();
130} 130}
131 131
132 132
133void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 133void DesktopPowerAlerter::hideEvent( QHideEvent *e )
134{ 134{
135 QMessageBox::hideEvent( e ); 135 QMessageBox::hideEvent( e );
136 alertCount = 0; 136 alertCount = 0;
137 currentPriority = INT_MAX; 137 currentPriority = INT_MAX;
138} 138}
139 139
140 140
141 141
142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
143 : QPEApplication( argc, argv, appType ) 143 : QPEApplication( argc, argv, appType )
144{ 144{
145 145
146 QTimer *t = new QTimer( this ); 146 QTimer *t = new QTimer( this );
147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
148 t->start( 10000 ); 148 t->start( 10000 );
149 ps = new PowerStatus; 149 ps = new PowerStatus;
150 pa = new DesktopPowerAlerter( 0 ); 150 pa = new DesktopPowerAlerter( 0 );
151 151
152 channel = new QCopChannel( "QPE/Desktop", this ); 152 channel = new QCopChannel( "QPE/Desktop", this );
153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
154 this, SLOT(receive(const QCString&, const QByteArray&)) ); 154 this, SLOT(receive(const QCString&, const QByteArray&)) );
155} 155}
156 156
157 157
158DesktopApplication::~DesktopApplication() 158DesktopApplication::~DesktopApplication()
159{ 159{
160 delete ps; 160 delete ps;
161 delete pa; 161 delete pa;
162} 162}
163 163
164void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 164void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
165{ 165{
166 QDataStream stream( data, IO_ReadOnly ); 166 QDataStream stream( data, IO_ReadOnly );
167 if (msg == "keyRegister(int key, QString channel, QString message)") 167 if (msg == "keyRegister(int key, QString channel, QString message)")
168 { 168 {
169 int k; 169 int k;
170 QString c, m; 170 QString c, m;
171 stream >> k; 171 stream >> k;
172 stream >> c; 172 stream >> c;
173 stream >> m; 173 stream >> m;
174 174
175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); 175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
176 keyRegisterList.append(QCopKeyRegister(k,c,m)); 176 keyRegisterList.append(QCopKeyRegister(k,c,m));
177 } 177 }
178 else if (msg == "suspend()"){ 178 else if (msg == "suspend()"){
179 emit power(); 179 emit power();
180 } 180 }
181 181
182} 182}
183 183
184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
185 185
186#ifdef Q_WS_QWS 186#ifdef Q_WS_QWS
187bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 187bool DesktopApplication::qwsEventFilter( QWSEvent *e )
188{ 188{
189 qpedesktop->checkMemory(); 189 qpedesktop->checkMemory();
190 190
191 if ( e->type == QWSEvent::Key ) { 191 if ( e->type == QWSEvent::Key ) {
192 QWSKeyEvent *ke = (QWSKeyEvent *)e; 192 QWSKeyEvent *ke = (QWSKeyEvent *)e;
193 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 193 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
194 return TRUE; 194 return TRUE;
195 bool press = ke->simpleData.is_press; 195 bool press = ke->simpleData.is_press;
196 bool autoRepeat= ke->simpleData.is_auto_repeat; 196 bool autoRepeat= ke->simpleData.is_auto_repeat;
197 197
198 /* 198 /*
199 app that registers key/message to be sent back to the app, when it doesn't have focus, 199 app that registers key/message to be sent back to the app, when it doesn't have focus,
200 when user presses key, unless keyboard has been requested from app. 200 when user presses key, unless keyboard has been requested from app.
201 will not send multiple repeats if user holds key 201 will not send multiple repeats if user holds key
202 i.e. one shot 202 i.e. one shot
203 203
204 */ 204 */
205 if (!keyRegisterList.isEmpty()) { 205 if (!keyRegisterList.isEmpty()) {
206 KeyRegisterList::Iterator it; 206 KeyRegisterList::Iterator it;
207 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 207 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
208 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { 208 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) {
209 if(press) qDebug("press"); else qDebug("release"); 209 if(press) qDebug("press"); else qDebug("release");
210 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 210 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 if ( !keyboardGrabbed() ) { 215 if ( !keyboardGrabbed() ) {
216 if ( ke->simpleData.keycode == Key_F9 ) { 216 if ( ke->simpleData.keycode == Key_F9 ) {
217 if ( press ) emit datebook(); 217 if ( press ) emit datebook();
218 return TRUE; 218 return TRUE;
219 } 219 }
220 if ( ke->simpleData.keycode == Key_F10 ) { 220 if ( ke->simpleData.keycode == Key_F10 ) {
221 if ( !press && cardSendTimer ) { 221 if ( !press && cardSendTimer ) {
222 emit contacts(); 222 emit contacts();
223 delete cardSendTimer; 223 delete cardSendTimer;
224 } else if ( press ) { 224 } else if ( press ) {
225 cardSendTimer = new QTimer(); 225 cardSendTimer = new QTimer();
226 cardSendTimer->start( 2000, TRUE ); 226 cardSendTimer->start( 2000, TRUE );
227 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 227 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
228 } 228 }
229 return TRUE; 229 return TRUE;
230 } 230 }
231 /* menu key now opens application menu/toolbar 231 /* menu key now opens application menu/toolbar
232 if ( ke->simpleData.keycode == Key_F11 ) { 232 if ( ke->simpleData.keycode == Key_F11 ) {
233 if ( press ) emit menu(); 233 if ( press ) emit menu();
234 return TRUE; 234 return TRUE;
235 } 235 }
236 */ 236 */
237 if ( ke->simpleData.keycode == Key_F12 ) { 237 if ( ke->simpleData.keycode == Key_F12 ) {
238 while( activePopupWidget() ) 238 while( activePopupWidget() )
239 activePopupWidget()->close(); 239 activePopupWidget()->close();
240 if ( press ) emit launch(); 240 if ( press ) emit launch();
241 return TRUE; 241 return TRUE;
242 } 242 }
243 if ( ke->simpleData.keycode == Key_F13 ) { 243 if ( ke->simpleData.keycode == Key_F13 ) {
244 if ( press ) emit email(); 244 if ( press ) emit email();
245 return TRUE; 245 return TRUE;
246 } 246 }
247 } 247 }
248 248
249 if ( ke->simpleData.keycode == Key_F34 ) { 249 if ( ke->simpleData.keycode == Key_F34 ) {
250 if ( press ) emit power(); 250 if ( press ) emit power();
251 return TRUE; 251 return TRUE;
252 } 252 }
253// This was used for the iPAQ PowerButton 253// This was used for the iPAQ PowerButton
254// See main.cpp for new KeyboardFilter 254// See main.cpp for new KeyboardFilter
255// 255//
256// if ( ke->simpleData.keycode == Key_SysReq ) { 256// if ( ke->simpleData.keycode == Key_SysReq ) {
257// if ( press ) emit power(); 257// if ( press ) emit power();
258// return TRUE; 258// return TRUE;
259// } 259// }
260 if ( ke->simpleData.keycode == Key_F35 ) { 260 if ( ke->simpleData.keycode == Key_F35 ) {
261 if ( press ) emit backlight(); 261 if ( press ) emit backlight();
262 return TRUE; 262 return TRUE;
263 } 263 }
264 if ( ke->simpleData.keycode == Key_F32 ) { 264 if ( ke->simpleData.keycode == Key_F32 ) {
265 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 265 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
266 return TRUE; 266 return TRUE;
267 } 267 }
268 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 268 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
269 if ( press ) emit symbol(); 269 if ( press ) emit symbol();
270 return TRUE; 270 return TRUE;
271 } 271 }
272 if ( ke->simpleData.keycode == Key_NumLock ) { 272 if ( ke->simpleData.keycode == Key_NumLock ) {
273 if ( press ) emit numLockStateToggle(); 273 if ( press ) emit numLockStateToggle();
274 } 274 }
275 if ( ke->simpleData.keycode == Key_CapsLock ) { 275 if ( ke->simpleData.keycode == Key_CapsLock ) {
276 if ( press ) emit capsLockStateToggle(); 276 if ( press ) emit capsLockStateToggle();
277 } 277 }
278 if (( press && !autoRepeat ) || ( !press && autoRepeat )) 278 if (( press && !autoRepeat ) || ( !press && autoRepeat ))
279 qpedesktop->keyClick(); 279 qpedesktop->keyClick();
280 } else { 280 } else {
281 if ( e->type == QWSEvent::Mouse ) { 281 if ( e->type == QWSEvent::Mouse ) {
282 QWSMouseEvent *me = (QWSMouseEvent *)e; 282 QWSMouseEvent *me = (QWSMouseEvent *)e;
283 static bool up = TRUE; 283 static bool up = TRUE;
284 if ( me->simpleData.state&LeftButton ) { 284 if ( me->simpleData.state&LeftButton ) {
285 if ( up ) { 285 if ( up ) {
286 up = FALSE; 286 up = FALSE;
287 qpedesktop->screenClick(); 287 qpedesktop->screenClick();
288 } 288 }
289 } else { 289 } else {
290 up = TRUE; 290 up = TRUE;
291 } 291 }
292 } 292 }
293 } 293 }
294 294
295 return QPEApplication::qwsEventFilter( e ); 295 return QPEApplication::qwsEventFilter( e );
296} 296}
297#endif 297#endif
298 298
299void DesktopApplication::psTimeout() 299void DesktopApplication::psTimeout()
300{ 300{
301 qpedesktop->checkMemory(); // in case no events are being generated 301 qpedesktop->checkMemory(); // in case no events are being generated
302 302
303 *ps = PowerStatusManager::readStatus(); 303 *ps = PowerStatusManager::readStatus();
304 304
305 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 305 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
306 pa->alert( tr( "Battery is running very low." ), 6 ); 306 pa->alert( tr( "Battery is running very low." ), 6 );
307 } 307 }
308 308
309 if ( ps->batteryStatus() == PowerStatus::Critical ) { 309 if ( ps->batteryStatus() == PowerStatus::Critical ) {
310 pa->alert( tr( "Battery level is critical!\n" 310 pa->alert( tr( "Battery level is critical!\n"
311 "Keep power off until power restored!" ), 1 ); 311 "Keep power off until power restored!" ), 1 );
312 } 312 }
313 313
314 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 314 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
315 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 315 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
316 } 316 }
317} 317}
318 318
319 319
320void DesktopApplication::sendCard() 320void DesktopApplication::sendCard()
321{ 321{
322 delete cardSendTimer; 322 delete cardSendTimer;
323 cardSendTimer = 0; 323 cardSendTimer = 0;
324 QString card = getenv("HOME"); 324 QString card = getenv("HOME");
325 card += "/Applications/addressbook/businesscard.vcf"; 325 card += "/Applications/addressbook/businesscard.vcf";
326 326
327 if ( QFile::exists( card ) ) { 327 if ( QFile::exists( card ) ) {
328 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 328 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
329 QString mimetype = "text/x-vCard"; 329 QString mimetype = "text/x-vCard";
330 e << tr("business card") << card << mimetype; 330 e << tr("business card") << card << mimetype;
331 } 331 }
332} 332}
333 333
334#if defined(QPE_HAVE_MEMALERTER) 334#if defined(QPE_HAVE_MEMALERTER)
335QPE_MEMALERTER_IMPL 335QPE_MEMALERTER_IMPL
336#endif 336#endif
337 337
338//=========================================================================== 338//===========================================================================
339 339
340Desktop::Desktop() : 340Desktop::Desktop() :
341 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 341 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
342 qcopBridge( 0 ), 342 qcopBridge( 0 ),
343 transferServer( 0 ), 343 transferServer( 0 ),
344 packageSlave( 0 ) 344 packageSlave( 0 )
345{ 345{
346 qpedesktop = this; 346 qpedesktop = this;
347 347
348// bg = new Info( this ); 348// bg = new Info( this );
349 tb = new TaskBar; 349 tb = new TaskBar;
350 350
351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
352 352
353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
355 355
356 int displayw = qApp->desktop()->width(); 356 int displayw = qApp->desktop()->width();
357 int displayh = qApp->desktop()->height(); 357 int displayh = qApp->desktop()->height();
358 358
359 359
360 QSize sz = tb->sizeHint(); 360 QSize sz = tb->sizeHint();
361 361
362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
364 364
365 tb->show(); 365 tb->show();
366 launcher->showMaximized(); 366 launcher->showMaximized();
367 launcher->show(); 367 launcher->show();
368 launcher->raise(); 368 launcher->raise();
369#if defined(QPE_HAVE_MEMALERTER) 369#if defined(QPE_HAVE_MEMALERTER)
370 initMemalerter(); 370 initMemalerter();
371#endif 371#endif
372 // start services 372 // start services
373 startTransferServer(); 373 startTransferServer();
374 (void) new IrServer( this ); 374 (void) new IrServer( this );
375 rereadVolumes(); 375 rereadVolumes();
376 376
377 packageSlave = new PackageSlave( this ); 377 packageSlave = new PackageSlave( this );
378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
379 379
380 qApp->installEventFilter( this ); 380 qApp->installEventFilter( this );
381} 381}
382 382
383void Desktop::show() 383void Desktop::show()
384{ 384{
385 login(TRUE); 385 login(TRUE);
386 QWidget::show(); 386 QWidget::show();
387} 387}
388 388
389Desktop::~Desktop() 389Desktop::~Desktop()
390{ 390{
391 delete launcher; 391 delete launcher;
392 delete tb; 392 delete tb;
393 delete qcopBridge; 393 delete qcopBridge;
394 delete transferServer; 394 delete transferServer;
395} 395}
396 396
397bool Desktop::recoverMemory() 397bool Desktop::recoverMemory()
398{ 398{
399 return tb->recoverMemory(); 399 return tb->recoverMemory();
400} 400}
401 401
402void Desktop::checkMemory() 402void Desktop::checkMemory()
403{ 403{
404#if defined(QPE_HAVE_MEMALERTER) 404#if defined(QPE_HAVE_MEMALERTER)
405 static bool ignoreNormal=FALSE; 405 static bool ignoreNormal=FALSE;
406 static bool existingMessage=FALSE; 406 static bool existingMessage=FALSE;
407 407
408 if(existingMessage) 408 if(existingMessage)
409 return; // don't show a second message while still on first 409 return; // don't show a second message while still on first
410 410
411 existingMessage = TRUE; 411 existingMessage = TRUE;
412 switch ( memstate ) { 412 switch ( memstate ) {
413 case Unknown: 413 case Unknown:
414 break; 414 break;
415 case Low: 415 case Low:
416 memstate = Unknown; 416 memstate = Unknown;
417 if ( recoverMemory() ) 417 if ( recoverMemory() )
418 ignoreNormal = TRUE; 418 ignoreNormal = TRUE;
419 else 419 else
420 QMessageBox::warning( 0 , "Memory Status", 420 QMessageBox::warning( 0 , "Memory Status",
421 "The memory smacks of shortage. \n" 421 "The memory smacks of shortage. \n"
422 "Please save data. " ); 422 "Please save data. " );
423 break; 423 break;
424 case Normal: 424 case Normal:
425 memstate = Unknown; 425 memstate = Unknown;
426 if ( ignoreNormal ) 426 if ( ignoreNormal )
427 ignoreNormal = FALSE; 427 ignoreNormal = FALSE;
428 else 428 else
429 QMessageBox::information ( 0 , "Memory Status", 429 QMessageBox::information ( 0 , "Memory Status",
430 "There is enough memory again." ); 430 "There is enough memory again." );
431 break; 431 break;
432 case VeryLow: 432 case VeryLow:
433 memstate = Unknown; 433 memstate = Unknown;
434 QMessageBox::critical( 0 , "Memory Status", 434 QMessageBox::critical( 0 , "Memory Status",
435 "The memory is very low. \n" 435 "The memory is very low. \n"
436 "Please end this application \n" 436 "Please end this application \n"
437 "immediately." ); 437 "immediately." );
438 recoverMemory(); 438 recoverMemory();
439 } 439 }
440 existingMessage = FALSE; 440 existingMessage = FALSE;
441#endif 441#endif
442} 442}
443 443
444static bool isVisibleWindow(int wid) 444static bool isVisibleWindow(int wid)
445{ 445{
446 const QList<QWSWindow> &list = qwsServer->clientWindows(); 446 const QList<QWSWindow> &list = qwsServer->clientWindows();
447 QWSWindow* w; 447 QWSWindow* w;
448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
449 if ( w->winId() == wid ) 449 if ( w->winId() == wid )
450 return !w->isFullyObscured(); 450 return !w->isFullyObscured();
451 } 451 }
452 return FALSE; 452 return FALSE;
453} 453}
454 454
455static bool hasVisibleWindow(const QString& clientname) 455static bool hasVisibleWindow(const QString& clientname)
456{ 456{
457 const QList<QWSWindow> &list = qwsServer->clientWindows(); 457 const QList<QWSWindow> &list = qwsServer->clientWindows();
458 QWSWindow* w; 458 QWSWindow* w;
459 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 459 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
460 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 460 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
461 return TRUE; 461 return TRUE;
462 } 462 }
463 return FALSE; 463 return FALSE;
464} 464}
465 465
466void Desktop::raiseLauncher() 466void Desktop::raiseLauncher()
467{ 467{
468 Config cfg("qpe"); //F12 'Home' 468 Config cfg("qpe"); //F12 'Home'
469 cfg.setGroup("AppsKey"); 469 cfg.setGroup("AppsKey");
470 QString tempItem; 470 QString tempItem;
471 tempItem = cfg.readEntry("Middle","Home"); 471 tempItem = cfg.readEntry("Middle","Home");
472 if(tempItem == "Home" || tempItem.isEmpty()) { 472 if(tempItem == "Home" || tempItem.isEmpty()) {
473 if ( isVisibleWindow(launcher->winId()) ) 473 if ( isVisibleWindow(launcher->winId()) )
474 launcher->nextView(); 474 launcher->nextView();
475 else 475 else
476 launcher->raise(); 476 launcher->raise();
477 } else { 477 } else {
478 QCopEnvelope e("QPE/System","execute(QString)"); 478 QCopEnvelope e("QPE/System","execute(QString)");
479 e << tempItem; 479 e << tempItem;
480 } 480 }
481} 481}
482 482
483void Desktop::executeOrModify(const QString& appLnkFile) 483void Desktop::executeOrModify(const QString& appLnkFile)
484{ 484{
485 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 485 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
486 if ( lnk.isValid() ) { 486 if ( lnk.isValid() ) {
487 QCString app = lnk.exec().utf8(); 487 QCString app = lnk.exec().utf8();
488 Global::terminateBuiltin("calibrate"); 488 Global::terminateBuiltin("calibrate");
489 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 489 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
490 MRUList::addTask(&lnk); 490 MRUList::addTask(&lnk);
491 if ( hasVisibleWindow(app) ) 491 if ( hasVisibleWindow(app) )
492 QCopChannel::send("QPE/Application/" + app, "nextView()"); 492 QCopChannel::send("QPE/Application/" + app, "nextView()");
493 else 493 else
494 QCopChannel::send("QPE/Application/" + app, "raise()"); 494 QCopChannel::send("QPE/Application/" + app, "raise()");
495 } else { 495 } else {
496 lnk.execute(); 496 lnk.execute();
497 } 497 }
498 } 498 }
499} 499}
500 500
501void Desktop::raiseDatebook() 501void Desktop::raiseDatebook()
502{ 502{
503 Config cfg("qpe"); //F9 'Activity' 503 Config cfg("qpe"); //F9 'Activity'
504 cfg.setGroup("AppsKey"); 504 cfg.setGroup("AppsKey");
505 QString tempItem; 505 QString tempItem;
506 tempItem = cfg.readEntry("LeftEnd","Calender"); 506 tempItem = cfg.readEntry("LeftEnd","Calender");
507 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); 507 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop");
508 else { 508 else {
509 QCopEnvelope e("QPE/System","execute(QString)"); 509 QCopEnvelope e("QPE/System","execute(QString)");
510 e << tempItem; 510 e << tempItem;
511 } 511 }
512} 512}
513 513
514void Desktop::raiseContacts() 514void Desktop::raiseContacts()
515{ 515{
516 Config cfg("qpe"); //F10, 'Contacts' 516 Config cfg("qpe"); //F10, 'Contacts'
517 cfg.setGroup("AppsKey"); 517 cfg.setGroup("AppsKey");
518 QString tempItem; 518 QString tempItem;
519 tempItem = cfg.readEntry("Left2nd","Address Book"); 519 tempItem = cfg.readEntry("Left2nd","Address Book");
520 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); 520 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop");
521 else { 521 else {
522 QCopEnvelope e("QPE/System","execute(QString)"); 522 QCopEnvelope e("QPE/System","execute(QString)");
523 e << tempItem; 523 e << tempItem;
524 } 524 }
525} 525}
526 526
527void Desktop::raiseMenu() 527void Desktop::raiseMenu()
528{ 528{
529 Config cfg("qpe"); //F11, 'Menu' 529 Config cfg("qpe"); //F11, 'Menu'
530 cfg.setGroup("AppsKey"); 530 cfg.setGroup("AppsKey");
531 QString tempItem; 531 QString tempItem;
532 tempItem = cfg.readEntry("Right2nd","Popup Menu"); 532 tempItem = cfg.readEntry("Right2nd","Popup Menu");
533 if(tempItem == "Popup Menu" || tempItem.isEmpty()) { 533 if(tempItem == "Popup Menu" || tempItem.isEmpty()) {
534 Global::terminateBuiltin("calibrate"); 534 Global::terminateBuiltin("calibrate");
535 tb->startMenu()->launch(); 535 tb->startMenu()->launch();
536 } else { 536 } else {
537 QCopEnvelope e("QPE/System","execute(QString)"); 537 QCopEnvelope e("QPE/System","execute(QString)");
538 e << tempItem; 538 e << tempItem;
539 } 539 }
540} 540}
541 541
542void Desktop::raiseEmail() 542void Desktop::raiseEmail()
543{ 543{
544 Config cfg("qpe"); //F13, 'Mail' 544 Config cfg("qpe"); //F13, 'Mail'
545 cfg.setGroup("AppsKey"); 545 cfg.setGroup("AppsKey");
546 QString tempItem; 546 QString tempItem;
547 tempItem = cfg.readEntry("RightEnd","Mail"); 547 tempItem = cfg.readEntry("RightEnd","Mail");
548 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); 548 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop");
549 else { 549 else {
550 QCopEnvelope e("QPE/System","execute(QString)"); 550 QCopEnvelope e("QPE/System","execute(QString)");
551 e << tempItem; 551 e << tempItem;
552 } 552 }
553} 553}
554 554
555// autoStarts apps on resume and start 555// autoStarts apps on resume and start
556void Desktop::execAutoStart() { 556void Desktop::execAutoStart() {
557 QString appName; 557 QString appName;
558 int delay; 558 int delay;
559 QDateTime now = QDateTime::currentDateTime(); 559 QDateTime now = QDateTime::currentDateTime();
560 Config cfg( "autostart" ); 560 Config cfg( "autostart" );
561 cfg.setGroup( "AutoStart" ); 561 cfg.setGroup( "AutoStart" );
562 appName = cfg.readEntry("Apps", ""); 562 appName = cfg.readEntry("Apps", "");
563 delay = (cfg.readEntry("Delay", "0" )).toInt(); 563 delay = (cfg.readEntry("Delay", "0" )).toInt();
564 // If the time between suspend and resume was longer then the 564 // If the time between suspend and resume was longer then the
565 // value saved as delay, start the app 565 // value saved as delay, start the app
566 if ( suspendTime.secsTo(now) >= (delay*60) ) { 566 if ( suspendTime.secsTo(now) >= (delay*60) ) {
567 QCopEnvelope e("QPE/System", "execute(QString)"); 567 QCopEnvelope e("QPE/System", "execute(QString)");
568 e << QString(appName); 568 e << QString(appName);
569 } //else { 569 } //else {
570 //} 570 //}
571} 571}
572 572
573#if defined(QPE_HAVE_TOGGLELIGHT) 573#if defined(QPE_HAVE_TOGGLELIGHT)
574#include <qpe/config.h> 574#include <qpe/config.h>
575 575
576#include <sys/ioctl.h> 576#include <sys/ioctl.h>
577#include <sys/types.h> 577#include <sys/types.h>
578#include <fcntl.h> 578#include <fcntl.h>
579#include <unistd.h> 579#include <unistd.h>
580#include <errno.h> 580#include <errno.h>
581#include <linux/ioctl.h> 581#include <linux/ioctl.h>
582#include <time.h> 582#include <time.h>
583#endif 583#endif
584 584
585static bool blanked=FALSE; 585static bool blanked=FALSE;
586 586
587static void blankScreen() 587static void blankScreen()
588{ 588{
589 if ( !qt_screen ) return; 589 if ( !qt_screen ) return;
590 /* Should use a big black window instead. 590 /* Should use a big black window instead.
591 QGfx* g = qt_screen->screenGfx(); 591 QGfx* g = qt_screen->screenGfx();
592 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 592 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
593 delete g; 593 delete g;
594 */ 594 */
595 blanked = TRUE; 595 blanked = TRUE;
596} 596}
597 597
598static void darkScreen() 598static void darkScreen()
599{ 599{
600 extern void qpe_setBacklight(int); 600 extern void qpe_setBacklight(int);
601 qpe_setBacklight(0); // force off 601 qpe_setBacklight(0); // force off
602} 602}
603 603
604 604
605void Desktop::togglePower() 605void Desktop::togglePower()
606{ 606{
607 bool wasloggedin = loggedin; 607 bool wasloggedin = loggedin;
608 loggedin=0; 608 loggedin=0;
609 suspendTime = QDateTime::currentDateTime(); 609 suspendTime = QDateTime::currentDateTime();
610 darkScreen(); 610 darkScreen();
611 if ( wasloggedin ) 611 if ( wasloggedin )
612 blankScreen(); 612 blankScreen();
613 613
614 system("apm --suspend"); 614 system("apm --suspend");
615 615
616 616
617 617
618 QWSServer::screenSaverActivate( FALSE ); 618 QWSServer::screenSaverActivate( FALSE );
619 { 619 {
620 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 620 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
621 QCopEnvelope e("QPE/System", "setBacklight(int)"); 621 QCopEnvelope e("QPE/System", "setBacklight(int)");
622 e << -3; // Force on 622 e << -3; // Force on
623 } 623 }
624 if ( wasloggedin ) { 624 if ( wasloggedin ) {
625 login(TRUE); 625 login(TRUE);
626 } 626 }
627 sleep(1); 627 sleep(1);
628 execAutoStart(); 628 execAutoStart();
629 //qcopBridge->closeOpenConnections(); 629 //qcopBridge->closeOpenConnections();
630 //qDebug("called togglePower()!!!!!!"); 630 //qDebug("called togglePower()!!!!!!");
631} 631}
632 632
633void Desktop::toggleLight() 633void Desktop::toggleLight()
634{ 634{
635 QCopEnvelope e("QPE/System", "setBacklight(int)"); 635 QCopEnvelope e("QPE/System", "setBacklight(int)");
636 e << -2; // toggle 636 e << -2; // toggle
637} 637}
638 638
639void Desktop::toggleSymbolInput() 639void Desktop::toggleSymbolInput()
640{ 640{
641 tb->toggleSymbolInput(); 641 tb->toggleSymbolInput();
642} 642}
643 643
644void Desktop::toggleNumLockState() 644void Desktop::toggleNumLockState()
645{ 645{
646 tb->toggleNumLockState(); 646 tb->toggleNumLockState();
647} 647}
648 648
649void Desktop::toggleCapsLockState() 649void Desktop::toggleCapsLockState()
650{ 650{
651 tb->toggleCapsLockState(); 651 tb->toggleCapsLockState();
652} 652}
653 653
654void Desktop::styleChange( QStyle &s ) 654void Desktop::styleChange( QStyle &s )
655{ 655{
656 QWidget::styleChange( s ); 656 QWidget::styleChange( s );
657 int displayw = qApp->desktop()->width(); 657 int displayw = qApp->desktop()->width();
658 int displayh = qApp->desktop()->height(); 658 int displayh = qApp->desktop()->height();
659 659
660 QSize sz = tb->sizeHint(); 660 QSize sz = tb->sizeHint();
661 661
662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
663} 663}
664 664
665void DesktopApplication::shutdown() 665void DesktopApplication::shutdown()
666{ 666{
667 if ( type() != GuiServer ) 667 if ( type() != GuiServer )
668 return; 668 return;
669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
671 this, SLOT(shutdown(ShutdownImpl::Type)) ); 671 this, SLOT(shutdown(ShutdownImpl::Type)) );
672 sd->showMaximized(); 672 sd->showMaximized();
673} 673}
674 674
675void DesktopApplication::shutdown( ShutdownImpl::Type t ) 675void DesktopApplication::shutdown( ShutdownImpl::Type t )
676{ 676{
677 switch ( t ) { 677 switch ( t ) {
678 case ShutdownImpl::ShutdownSystem: 678 case ShutdownImpl::ShutdownSystem:
679 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 679 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
680 break; 680 break;
681 case ShutdownImpl::RebootSystem: 681 case ShutdownImpl::RebootSystem:
682 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 682 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
683 break; 683 break;
684 case ShutdownImpl::RestartDesktop: 684 case ShutdownImpl::RestartDesktop:
685 restart(); 685 restart();
686 break; 686 break;
687 case ShutdownImpl::TerminateDesktop: 687 case ShutdownImpl::TerminateDesktop:
688 prepareForTermination(FALSE); 688 prepareForTermination(FALSE);
689
690 // This is a workaround for a Qt bug
691 // clipboard applet has to stop its poll timer, or Qt/E
692 // will hang on quit() right before it emits aboutToQuit()
693 emit aboutToQuit ( );
694
689 quit(); 695 quit();
690 break; 696 break;
691 } 697 }
692} 698}
693 699
694void DesktopApplication::restart() 700void DesktopApplication::restart()
695{ 701{
696 prepareForTermination(TRUE); 702 prepareForTermination(TRUE);
697 703
698#ifdef Q_WS_QWS 704#ifdef Q_WS_QWS
699 for ( int fd = 3; fd < 100; fd++ ) 705 for ( int fd = 3; fd < 100; fd++ )
700 close( fd ); 706 close( fd );
701#if defined(QT_DEMO_SINGLE_FLOPPY) 707#if defined(QT_DEMO_SINGLE_FLOPPY)
702 execl( "/sbin/init", "qpe", 0 ); 708 execl( "/sbin/init", "qpe", 0 );
703#elif defined(QT_QWS_CASSIOPEIA) 709#elif defined(QT_QWS_CASSIOPEIA)
704 execl( "/bin/sh", "sh", 0 ); 710 execl( "/bin/sh", "sh", 0 );
705#else 711#else
706 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 712 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
707#endif 713#endif
708 exit(1); 714 exit(1);
709#endif 715#endif
710} 716}
711 717
712void Desktop::startTransferServer() 718void Desktop::startTransferServer()
713{ 719{
714 // start qcop bridge server 720 // start qcop bridge server
715 qcopBridge = new QCopBridge( 4243 ); 721 qcopBridge = new QCopBridge( 4243 );
716 if ( !qcopBridge->ok() ) { 722 if ( !qcopBridge->ok() ) {
717 delete qcopBridge; 723 delete qcopBridge;
718 qcopBridge = 0; 724 qcopBridge = 0;
719 } 725 }
720 // start transfer server 726 // start transfer server
721 transferServer = new TransferServer( 4242 ); 727 transferServer = new TransferServer( 4242 );
722 if ( !transferServer->ok() ) { 728 if ( !transferServer->ok() ) {
723 delete transferServer; 729 delete transferServer;
724 transferServer = 0; 730 transferServer = 0;
725 } 731 }
726 if ( !transferServer || !qcopBridge ) 732 if ( !transferServer || !qcopBridge )
727 startTimer( 2000 ); 733 startTimer( 2000 );
728} 734}
729 735
730void Desktop::timerEvent( QTimerEvent *e ) 736void Desktop::timerEvent( QTimerEvent *e )
731{ 737{
732 killTimer( e->timerId() ); 738 killTimer( e->timerId() );
733 startTransferServer(); 739 startTransferServer();
734} 740}
735 741
736void Desktop::terminateServers() 742void Desktop::terminateServers()
737{ 743{
738 delete transferServer; 744 delete transferServer;
739 delete qcopBridge; 745 delete qcopBridge;
740 transferServer = 0; 746 transferServer = 0;
741 qcopBridge = 0; 747 qcopBridge = 0;
742} 748}
743 749
744void Desktop::rereadVolumes() 750void Desktop::rereadVolumes()
745{ 751{
746 Config cfg("qpe"); 752 Config cfg("qpe");
747 cfg.setGroup("Volume"); 753 cfg.setGroup("Volume");
748 touchclick = cfg.readBoolEntry("TouchSound"); 754 touchclick = cfg.readBoolEntry("TouchSound");
749 keyclick = cfg.readBoolEntry("KeySound"); 755 keyclick = cfg.readBoolEntry("KeySound");
750 alarmsound = cfg.readBoolEntry("AlarmSound"); 756 alarmsound = cfg.readBoolEntry("AlarmSound");
751// Config cfg("Sound"); 757// Config cfg("Sound");
752// cfg.setGroup("System"); 758// cfg.setGroup("System");
753// touchclick = cfg.readBoolEntry("Touch"); 759// touchclick = cfg.readBoolEntry("Touch");
754// keyclick = cfg.readBoolEntry("Key"); 760// keyclick = cfg.readBoolEntry("Key");
755} 761}
756 762
757void Desktop::keyClick() 763void Desktop::keyClick()
758{ 764{
759 if ( keyclick ) 765 if ( keyclick )
760 ODevice::inst ( )-> keySound ( ); 766 ODevice::inst ( )-> keySound ( );
761} 767}
762 768
763void Desktop::screenClick() 769void Desktop::screenClick()
764{ 770{
765 if ( touchclick ) 771 if ( touchclick )
766 ODevice::inst ( )-> touchSound ( ); 772 ODevice::inst ( )-> touchSound ( );
767} 773}
768 774
769void Desktop::soundAlarm() 775void Desktop::soundAlarm()
770{ 776{
771 if ( qpedesktop-> alarmsound ) 777 if ( qpedesktop-> alarmsound )
772 ODevice::inst ( )-> alarmSound ( ); 778 ODevice::inst ( )-> alarmSound ( );
773} 779}
774 780
775bool Desktop::eventFilter( QObject *, QEvent *ev ) 781bool Desktop::eventFilter( QObject *, QEvent *ev )
776{ 782{
777 if ( ev-> type ( ) == QEvent::KeyPress ) { 783 if ( ev-> type ( ) == QEvent::KeyPress ) {
778 QKeyEvent *ke = (QKeyEvent *) ev; 784 QKeyEvent *ke = (QKeyEvent *) ev;
779 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key 785 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
780 QWidget *active = qApp-> activeWindow ( ); 786 QWidget *active = qApp-> activeWindow ( );
781 787
782 if ( active && active-> isPopup ( )) 788 if ( active && active-> isPopup ( ))
783 active->close(); 789 active->close();
784 790
785 raiseMenu ( ); 791 raiseMenu ( );
786 return true; 792 return true;
787 } 793 }
788 } 794 }
789 return false; 795 return false;
790} 796}