summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-08-09 17:42:14 (UTC)
committer kergoth <kergoth>2003-08-09 17:42:14 (UTC)
commit1ab4ca95e4d2cf24d32b38c9031cb6076351e730 (patch) (unidiff)
tree644d196b01c7f280981bd17da23c7592a18e5643
parentec14206f63dd93e9fb84c76cbc76fc1968637590 (diff)
downloadopie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.zip
opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.gz
opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.bz2
Merge from BRANCH_1_0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/.cvsignore1
-rw-r--r--core/apps/embeddedkonsole/MyPty.cpp3
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp48
-rw-r--r--core/apps/helpbrowser/helpbrowser.h4
-rw-r--r--core/apps/helpbrowser/helpbrowser.pro4
-rw-r--r--core/apps/helpbrowser/magictextbrowser.cpp99
-rw-r--r--core/apps/helpbrowser/magictextbrowser.h42
-rw-r--r--core/apps/helpbrowser/main.cpp9
-rw-r--r--core/apps/textedit/textedit.cpp8
-rw-r--r--core/opie-login/main.cpp30
-rw-r--r--core/opie-login/opie-login.conffiles1
-rw-r--r--core/opiealarm/Makefile4
-rw-r--r--core/opiealarm/config.in2
-rw-r--r--core/opiealarm/opiealarm.c7
-rw-r--r--core/settings/launcher/tabdialog.cpp6
-rw-r--r--core/settings/security/security.cpp258
-rw-r--r--core/settings/security/security.h6
-rw-r--r--core/settings/security/securitybase.ui465
18 files changed, 723 insertions, 274 deletions
diff --git a/core/apps/.cvsignore b/core/apps/.cvsignore
index faa68ae..6d678c6 100644
--- a/core/apps/.cvsignore
+++ b/core/apps/.cvsignore
@@ -1,2 +1 @@
1binconfig.in
2config.in config.in
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp
index 9adc248..7e820ad 100644
--- a/core/apps/embeddedkonsole/MyPty.cpp
+++ b/core/apps/embeddedkonsole/MyPty.cpp
@@ -1,283 +1,284 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [MyPty.C] Pseudo Terminal Device */ 3/* [MyPty.C] Pseudo Terminal Device */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* -------------------------------------------------------------------------- */ 10/* -------------------------------------------------------------------------- */
11/* */ 11/* */
12/* Ported Konsole to Qt/Embedded */ 12/* Ported Konsole to Qt/Embedded */
13/* */ 13/* */
14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 14/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
15/* */ 15/* */
16/* -------------------------------------------------------------------------- */ 16/* -------------------------------------------------------------------------- */
17 17
18/* If you're compiling konsole on non-Linux platforms and find 18/* If you're compiling konsole on non-Linux platforms and find
19 problems that you can track down to this file, please have 19 problems that you can track down to this file, please have
20 a look into ../README.ports, too. 20 a look into ../README.ports, too.
21*/ 21*/
22 22
23/*! \file 23/*! \file
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66 66
67#include <qfileinfo.h> 67#include <qfileinfo.h>
68#include <qapplication.h> 68#include <qapplication.h>
69#include <qsocketnotifier.h> 69#include <qsocketnotifier.h>
70#include <qstring.h> 70#include <qstring.h>
71 71
72#include <stdlib.h> 72#include <stdlib.h>
73#include <stdio.h> 73#include <stdio.h>
74#include <signal.h> 74#include <signal.h>
75#include <fcntl.h> 75#include <fcntl.h>
76#include <unistd.h> 76#include <unistd.h>
77#include <termios.h> 77#include <termios.h>
78#include <sys/types.h> 78#include <sys/types.h>
79#include <sys/ioctl.h> 79#include <sys/ioctl.h>
80#include <sys/wait.h> 80#include <sys/wait.h>
81 81
82#ifdef HAVE_OPENPTY 82#ifdef HAVE_OPENPTY
83#include <pty.h> 83#include <pty.h>
84#endif 84#endif
85 85
86#include "MyPty.h" 86#include "MyPty.h"
87 87
88 88
89#undef VERBOSE_DEBUG 89#undef VERBOSE_DEBUG
90 90
91 91
92/* -------------------------------------------------------------------------- */ 92/* -------------------------------------------------------------------------- */
93 93
94/*! 94/*!
95 Informs the client program about the 95 Informs the client program about the
96 actual size of the window. 96 actual size of the window.
97*/ 97*/
98 98
99void MyPty::setSize(int lines, int columns) 99void MyPty::setSize(int lines, int columns)
100{ 100{
101 struct winsize wsize; 101 struct winsize wsize;
102 wsize.ws_row = (unsigned short)lines; 102 wsize.ws_row = (unsigned short)lines;
103 wsize.ws_col = (unsigned short)columns; 103 wsize.ws_col = (unsigned short)columns;
104 if(fd < 0) return; 104 if(fd < 0) return;
105 ioctl(fd,TIOCSWINSZ,(char *)&wsize); 105 ioctl(fd,TIOCSWINSZ,(char *)&wsize);
106} 106}
107 107
108 108
109void MyPty::donePty() 109void MyPty::donePty()
110{ 110{
111 // This is code from the Qt DumbTerminal example 111 // This is code from the Qt DumbTerminal example
112 int status = 0; 112 int status = 0;
113 113
114 ::close(fd); 114 ::close(fd);
115 115
116 if (cpid) { 116 if (cpid) {
117 kill(cpid, SIGHUP); 117 kill(cpid, SIGHUP);
118 waitpid(cpid, &status, 0); 118 waitpid(cpid, &status, 0);
119 } 119 }
120 120
121 emit done(status); 121 emit done(status);
122} 122}
123 123
124 124
125const char* MyPty::deviceName() 125const char* MyPty::deviceName()
126{ 126{
127 return ttynam; 127 return ttynam;
128} 128}
129 129
130 130
131void MyPty::error() 131void MyPty::error()
132{ 132{
133 // This is code from the Qt DumbTerminal example 133 // This is code from the Qt DumbTerminal example
134 donePty(); 134 donePty();
135} 135}
136 136
137 137
138/*! 138/*!
139 start the client program. 139 start the client program.
140*/ 140*/
141int MyPty::run(const char* cmd, QStrList &, const char*, int) 141int MyPty::run(const char* cmd, QStrList &, const char*, int)
142{ 142{
143 // This is code from the Qt DumbTerminal example 143 // This is code from the Qt DumbTerminal example
144 cpid = fork(); 144 cpid = fork();
145 145
146 if ( !cpid ) { 146 if ( !cpid ) {
147 // child - exec shell on tty 147 // child - exec shell on tty
148 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 148 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
149 int ttyfd = open(ttynam, O_RDWR); 149 int ttyfd = open(ttynam, O_RDWR);
150 dup2(ttyfd, STDIN_FILENO); 150 dup2(ttyfd, STDIN_FILENO);
151 dup2(ttyfd, STDOUT_FILENO); 151 dup2(ttyfd, STDOUT_FILENO);
152 dup2(ttyfd, STDERR_FILENO); 152 dup2(ttyfd, STDERR_FILENO);
153 // should be done with tty, so close it 153 // should be done with tty, so close it
154 close(ttyfd); 154 close(ttyfd);
155 static struct termios ttmode; 155 static struct termios ttmode;
156 if ( setsid() < 0 ) 156 if ( setsid() < 0 )
157 perror( "failed to set process group" ); 157 perror( "failed to set process group" );
158#if defined (TIOCSCTTY) 158#if defined (TIOCSCTTY)
159 // grabbed from APUE by Stevens 159 // grabbed from APUE by Stevens
160 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 160 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
161#endif 161#endif
162 tcgetattr( STDIN_FILENO, &ttmode ); 162 tcgetattr( STDIN_FILENO, &ttmode );
163 ttmode.c_cc[VINTR] = 3; 163 ttmode.c_cc[VINTR] = 3;
164 ttmode.c_cc[VERASE] = 8; 164 ttmode.c_cc[VERASE] = 8;
165 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 165 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
166 setenv("TERM","vt100",1); 166 if(strlen(getenv("TERM"))<=0)
167 setenv("TERM","vt100",1);
167 setenv("COLORTERM","0",1); 168 setenv("COLORTERM","0",1);
168 169
169 if (getuid() == 0) { 170 if (getuid() == 0) {
170 char msg[] = "WARNING: You are running this shell as root!\n"; 171 char msg[] = "WARNING: You are running this shell as root!\n";
171 write(ttyfd, msg, sizeof(msg)); 172 write(ttyfd, msg, sizeof(msg));
172 } 173 }
173 174
174 QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell 175 QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell
175 176
176 execl(cmd, ccmd.latin1(), 0); 177 execl(cmd, ccmd.latin1(), 0);
177 178
178 donePty(); 179 donePty();
179 exit(-1); 180 exit(-1);
180 } 181 }
181 182
182 // parent - continue as a widget 183 // parent - continue as a widget
183 QSocketNotifier* sn_r = new QSocketNotifier(fd,QSocketNotifier::Read,this); 184 QSocketNotifier* sn_r = new QSocketNotifier(fd,QSocketNotifier::Read,this);
184 QSocketNotifier* sn_e = new QSocketNotifier(fd,QSocketNotifier::Exception,this); 185 QSocketNotifier* sn_e = new QSocketNotifier(fd,QSocketNotifier::Exception,this);
185 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 186 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
186 connect(sn_e,SIGNAL(activated(int)),this,SLOT(error())); 187 connect(sn_e,SIGNAL(activated(int)),this,SLOT(error()));
187 188
188 return 0; 189 return 0;
189} 190}
190 191
191int MyPty::openPty() 192int MyPty::openPty()
192{ 193{
193 // This is code from the Qt DumbTerminal example 194 // This is code from the Qt DumbTerminal example
194 int ptyfd = -1; 195 int ptyfd = -1;
195 196
196#ifdef HAVE_OPENPTY 197#ifdef HAVE_OPENPTY
197 int ttyfd; 198 int ttyfd;
198 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) 199 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
199 ptyfd = -1; 200 ptyfd = -1;
200 else 201 else
201 close(ttyfd); // we open the ttynam ourselves. 202 close(ttyfd); // we open the ttynam ourselves.
202#else 203#else
203 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 204 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
204 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 205 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
205 sprintf(ptynam,"/dev/pty%c%c",*c0,*c1); 206 sprintf(ptynam,"/dev/pty%c%c",*c0,*c1);
206 sprintf(ttynam,"/dev/tty%c%c",*c0,*c1); 207 sprintf(ttynam,"/dev/tty%c%c",*c0,*c1);
207 if ((ptyfd = ::open(ptynam,O_RDWR)) >= 0) { 208 if ((ptyfd = ::open(ptynam,O_RDWR)) >= 0) {
208 if (geteuid() != 0 && !access(ttynam,R_OK|W_OK) == 0) { 209 if (geteuid() != 0 && !access(ttynam,R_OK|W_OK) == 0) {
209 ::close(ptyfd); 210 ::close(ptyfd);
210 ptyfd = -1; 211 ptyfd = -1;
211 } 212 }
212 } 213 }
213 } 214 }
214 } 215 }
215#endif 216#endif
216 217
217 if ( ptyfd < 0 ) { 218 if ( ptyfd < 0 ) {
218 qApp->exit(1); 219 qApp->exit(1);
219 return -1; 220 return -1;
220 } 221 }
221 222
222 return ptyfd; 223 return ptyfd;
223} 224}
224 225
225/*! 226/*!
226 Create an instance. 227 Create an instance.
227*/ 228*/
228MyPty::MyPty() : cpid(0) 229MyPty::MyPty() : cpid(0)
229{ 230{
230 fd = openPty(); 231 fd = openPty();
231} 232}
232 233
233/*! 234/*!
234 Destructor. 235 Destructor.
235 Note that the related client program is not killed 236 Note that the related client program is not killed
236 (yet) when a instance is deleted. 237 (yet) when a instance is deleted.
237*/ 238*/
238MyPty::~MyPty() 239MyPty::~MyPty()
239{ 240{
240 donePty(); 241 donePty();
241} 242}
242 243
243 244
244/*! sends len bytes through the line */ 245/*! sends len bytes through the line */
245void MyPty::send_bytes(const char* s, int len) 246void MyPty::send_bytes(const char* s, int len)
246{ 247{
247 248
248#ifdef VERBOSE_DEBUG 249#ifdef VERBOSE_DEBUG
249 // verbose debug 250 // verbose debug
250 printf("sending bytes:\n"); 251 printf("sending bytes:\n");
251 for (int i = 0; i < len; i++) 252 for (int i = 0; i < len; i++)
252 printf("%c", s[i]); 253 printf("%c", s[i]);
253 printf("\n"); 254 printf("\n");
254#endif 255#endif
255 256
256 ::write(fd, s, len); 257 ::write(fd, s, len);
257} 258}
258 259
259/*! indicates that a block of data is received */ 260/*! indicates that a block of data is received */
260void MyPty::readPty() 261void MyPty::readPty()
261{ 262{
262 char buf[4096]; 263 char buf[4096];
263 264
264 int len = ::read( fd, buf, 4096 ); 265 int len = ::read( fd, buf, 4096 );
265 266
266 if (len == -1) 267 if (len == -1)
267 donePty(); 268 donePty();
268 269
269 if (len < 0) 270 if (len < 0)
270 return; 271 return;
271 272
272 emit block_in(buf,len); 273 emit block_in(buf,len);
273 274
274#ifdef VERBOSE_DEBUG 275#ifdef VERBOSE_DEBUG
275 // verbose debug 276 // verbose debug
276 printf("read bytes:\n"); 277 printf("read bytes:\n");
277 for (int i = 0; i < len; i++) 278 for (int i = 0; i < len; i++)
278 printf("%c", buf[i]); 279 printf("%c", buf[i]);
279 printf("\n"); 280 printf("\n");
280#endif 281#endif
281 282
282} 283}
283 284
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp
index 48da7c6..531dbff 100644
--- a/core/apps/helpbrowser/helpbrowser.cpp
+++ b/core/apps/helpbrowser/helpbrowser.cpp
@@ -1,228 +1,250 @@
1#/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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#define QTOPIA_INTERNAL_LANGLIST
22
21#include "helpbrowser.h" 23#include "helpbrowser.h"
22 24
23#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
24#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/mimetype.h>
28#include <qpe/applnk.h>
25#include <qpe/global.h> 29#include <qpe/global.h>
26 30
27#include <qstatusbar.h> 31#include <qstatusbar.h>
28#include <qdragobject.h> 32#include <qdragobject.h>
29#include <qpixmap.h> 33#include <qpixmap.h>
30#include <qpopupmenu.h> 34#include <qpopupmenu.h>
31#include <qpe/qpemenubar.h> 35#include <qpe/qpemenubar.h>
32#include <qpe/qpetoolbar.h> 36#include <qpe/qpetoolbar.h>
37#include <qpe/qcopenvelope_qws.h>
33#include <qtoolbutton.h> 38#include <qtoolbutton.h>
34#include <qiconset.h> 39#include <qiconset.h>
35#include <qfile.h> 40#include <qfile.h>
36#include <qtextstream.h> 41#include <qtextstream.h>
37#include <qstylesheet.h> 42#include <qstylesheet.h>
38#include <qmessagebox.h> 43#include <qmessagebox.h>
39#include <qfiledialog.h> 44#include <qfiledialog.h>
40#include <qevent.h> 45#include <qevent.h>
41#include <qlineedit.h> 46#include <qlineedit.h>
42#include <qobjectlist.h> 47#include <qobjectlist.h>
43#include <qfileinfo.h> 48#include <qfileinfo.h>
44#include <qfile.h> 49#include <qfile.h>
45#include <qdatastream.h> 50#include <qdatastream.h>
46#include <qprinter.h> 51#include <qprinter.h>
47#include <qsimplerichtext.h> 52#include <qsimplerichtext.h>
48#include <qpaintdevicemetrics.h> 53#include <qpaintdevicemetrics.h>
49#include <qaction.h> 54#include <qaction.h>
50 55
51#include <ctype.h> 56#include <cctype>
52 57
58#include "magictextbrowser.h"
53 59
54HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) 60HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
55 : QMainWindow( parent, name, f ), 61 : QMainWindow( parent, name, f ),
56 selectedURL() 62 selectedURL()
57{ 63{
58 init( "index.html" ); 64 init( "index.html" );
59} 65}
60 66
67
68
61void HelpBrowser::init( const QString& _home ) 69void HelpBrowser::init( const QString& _home )
62{ 70{
63 setIcon( Resource::loadPixmap( "help_icon" ) ); 71 setIcon( Resource::loadPixmap( "HelpBrowser" ) );
72 setBackgroundMode( PaletteButton );
64 73
65 browser = new QTextBrowser( this ); 74 browser = new MagicTextBrowser( this );
66 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 75 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
67 connect( browser, SIGNAL( textChanged() ), 76 connect( browser, SIGNAL( textChanged() ),
68 this, SLOT( textChanged() ) ); 77 this, SLOT( textChanged() ) );
69 78
70 setCentralWidget( browser ); 79 setCentralWidget( browser );
71 setToolBarsMovable( FALSE ); 80 setToolBarsMovable( FALSE );
72 81
73 if ( !_home.isEmpty() ) 82 if ( !_home.isEmpty() )
74 browser->setSource( _home ); 83 browser->setSource( _home );
75 84
76 QPEToolBar* toolbar = new QPEToolBar( this ); 85 QPEToolBar* toolbar = new QPEToolBar( this );
77 toolbar->setHorizontalStretchable( TRUE ); 86 toolbar->setHorizontalStretchable( TRUE );
78 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 87 QPEMenuBar *menu = new QPEMenuBar( toolbar );
79 88
80 toolbar = new QPEToolBar( this ); 89 toolbar = new QPEToolBar( this );
81 // addToolBar( toolbar, "Toolbar"); 90 // addToolBar( toolbar, "Toolbar");
82 91
83 //QPopupMenu* go = new QPopupMenu( this ); 92 QPopupMenu* go = new QPopupMenu( this );
84 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); 93 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
85 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); 94 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
86 connect( browser, SIGNAL( backwardAvailable( bool ) ), 95 connect( browser, SIGNAL( backwardAvailable( bool ) ),
87 backAction, SLOT( setEnabled( bool ) ) ); 96 backAction, SLOT( setEnabled( bool ) ) );
88 //backAction->addTo( go ); 97 backAction->addTo( go );
89 backAction->addTo( toolbar ); 98 backAction->addTo( toolbar );
90 backAction->setEnabled( FALSE ); 99 backAction->setEnabled( FALSE );
91 100
92 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); 101 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
93 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); 102 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
94 connect( browser, SIGNAL( forwardAvailable( bool ) ), 103 connect( browser, SIGNAL( forwardAvailable( bool ) ),
95 forwardAction, SLOT( setEnabled( bool ) ) ); 104 forwardAction, SLOT( setEnabled( bool ) ) );
96 //forwardAction->addTo( go ); 105 forwardAction->addTo( go );
97 forwardAction->addTo( toolbar ); 106 forwardAction->addTo( toolbar );
98 forwardAction->setEnabled( FALSE ); 107 forwardAction->setEnabled( FALSE );
99 108
100 QAction *a = new QAction( tr( "Home" ), Resource::loadPixmap( 109 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 );
101"home" ), QString::null, 0, this, 0 );
102 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); 110 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
103 //a->addTo( go ); 111 a->addTo( go );
104 a->addTo( toolbar ); 112 a->addTo( toolbar );
105 113
106 bookm = new QPopupMenu( this ); 114 bookm = new QPopupMenu( this );
107 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); 115 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
108 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); 116 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
109 bookm->insertSeparator(); 117 bookm->insertSeparator();
110 connect( bookm, SIGNAL( activated( int ) ), 118 connect( bookm, SIGNAL( activated( int ) ),
111 this, SLOT( bookmChosen( int ) ) ); 119 this, SLOT( bookmChosen( int ) ) );
112 120
113 readBookmarks(); 121 readBookmarks();
114 122
115 //menu->insertItem( tr("Go"), go ); 123 menu->insertItem( tr("Go"), go );
116 menu->insertItem( tr( "Bookmarks" ), bookm ); 124 menu->insertItem( tr( "Bookmarks" ), bookm );
117 125
118 resize( 240, 300 ); 126 resize( 240, 300 );
119 browser->setFocus(); 127 browser->setFocus();
128 browser->setFrameStyle( QFrame::NoFrame );
129
130#if !defined(QT_NO_COP)
131 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this );
132 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
133 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
134#endif
120 135
121 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 136 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
122 this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 137 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
123} 138}
124 139
125void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) 140void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
126{ 141{
142 qDebug("reached appMessage");
127 if ( msg == "showFile(QString)" ) { 143 if ( msg == "showFile(QString)" ) {
128 QDataStream ds(data,IO_ReadOnly); 144 QDataStream ds(data,IO_ReadOnly);
129 QString fn; 145 QString fn;
130 ds >> fn; 146 ds >> fn;
131 setDocument( fn ); 147 setDocument( fn );
148
149 QPEApplication::setKeepRunning();
150
151 showMaximized();
152 setActiveWindow();
153 raise();
132 } 154 }
133} 155}
134 156
135void HelpBrowser::setDocument( const QString &doc ) 157void HelpBrowser::setDocument( const QString &doc )
136{ 158{
137 if ( !doc.isEmpty() ) 159 if ( !doc.isEmpty() )
138 browser->setSource( doc ); 160 browser->setSource( doc );
139 raise(); 161 raise();
140} 162}
141 163
142 164
143void HelpBrowser::textChanged() 165void HelpBrowser::textChanged()
144{ 166{
145 if ( browser->documentTitle().isNull() ) 167 if ( browser->documentTitle().isNull() )
146 setCaption( tr("Help Browser") ); 168 setCaption( tr("Help Browser") );
147 else 169 else
148 setCaption( browser->documentTitle() ) ; 170 setCaption( browser->documentTitle() ) ;
149 171
150 selectedURL = caption(); 172 selectedURL = caption();
151} 173}
152 174
153HelpBrowser::~HelpBrowser() 175HelpBrowser::~HelpBrowser()
154{ 176{
155 QStringList bookmarks; 177 QStringList bookmarks;
156 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); 178 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin();
157 for ( ; it2 != mBookmarks.end(); ++it2 ) 179 for ( ; it2 != mBookmarks.end(); ++it2 )
158 bookmarks.append( (*it2).name + "=" + (*it2).file ); 180 bookmarks.append( (*it2).name + "=" + (*it2).file );
159 181
160 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); 182 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") );
161 if ( f2.open( IO_WriteOnly ) ) { 183 if ( f2.open( IO_WriteOnly ) ) {
162 QDataStream s2( &f2 ); 184 QDataStream s2( &f2 );
163 s2 << bookmarks; 185 s2 << bookmarks;
164 f2.close(); 186 f2.close();
165 } 187 }
166} 188}
167 189
168void HelpBrowser::pathSelected( const QString &_path ) 190void HelpBrowser::pathSelected( const QString &_path )
169{ 191{
170 browser->setSource( _path ); 192 browser->setSource( _path );
171} 193}
172 194
173void HelpBrowser::readBookmarks() 195void HelpBrowser::readBookmarks()
174{ 196{
175 QString file = Global::applicationFileName("helpbrowser", "bookmarks"); 197 QString file = Global::applicationFileName("helpbrowser", "bookmarks");
176 if ( QFile::exists( file ) ) { 198 if ( QFile::exists( file ) ) {
177 QStringList bookmarks; 199 QStringList bookmarks;
178 QFile f( file ); 200 QFile f( file );
179 if ( f.open( IO_ReadOnly ) ) { 201 if ( f.open( IO_ReadOnly ) ) {
180 QDataStream s( &f ); 202 QDataStream s( &f );
181 s >> bookmarks; 203 s >> bookmarks;
182 f.close(); 204 f.close();
183 } 205 }
184 QStringList::Iterator it = bookmarks.begin(); 206 QStringList::Iterator it = bookmarks.begin();
185 for ( ; it != bookmarks.end(); ++it ) { 207 for ( ; it != bookmarks.end(); ++it ) {
186 Bookmark b; 208 Bookmark b;
187 QString current = *it; 209 QString current = *it;
188 int equal = current.find( "=" ); 210 int equal = current.find( "=" );
189 if ( equal < 1 || equal == (int)current.length() - 1 ) 211 if ( equal < 1 || equal == (int)current.length() - 1 )
190 continue; 212 continue;
191 b.name = current.left( equal ); 213 b.name = current.left( equal );
192 b.file = current.mid( equal + 1 ); 214 b.file = current.mid( equal + 1 );
193 mBookmarks[ bookm->insertItem( b.name ) ] = b; 215 mBookmarks[ bookm->insertItem( b.name ) ] = b;
194 } 216 }
195 } 217 }
196} 218}
197 219
198void HelpBrowser::bookmChosen( int i ) 220void HelpBrowser::bookmChosen( int i )
199{ 221{
200 if ( mBookmarks.contains( i ) ) 222 if ( mBookmarks.contains( i ) )
201 browser->setSource( mBookmarks[ i ].file ); 223 browser->setSource( mBookmarks[ i ].file );
202} 224}
203 225
204void HelpBrowser::addBookmark() 226void HelpBrowser::addBookmark()
205{ 227{
206 Bookmark b; 228 Bookmark b;
207 b.name = browser->documentTitle(); 229 b.name = browser->documentTitle();
208 b.file = browser->source(); 230 b.file = browser->source();
209 if (b.name.isEmpty() ) { 231 if (b.name.isEmpty() ) {
210 b.name = b.file.left( b.file.length() - 5 ); // remove .html 232 b.name = b.file.left( b.file.length() - 5 ); // remove .html
211 } 233 }
212 QMap<int, Bookmark>::Iterator it; 234 QMap<int, Bookmark>::Iterator it;
213 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) 235 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it )
214 if ( (*it).file == b.file ) return; 236 if ( (*it).file == b.file ) return;
215 mBookmarks[ bookm->insertItem( b.name ) ] = b; 237 mBookmarks[ bookm->insertItem( b.name ) ] = b;
216} 238}
217 239
218void HelpBrowser::removeBookmark() 240void HelpBrowser::removeBookmark()
219{ 241{
220 QString file = browser->source(); 242 QString file = browser->source();
221 QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); 243 QMap<int, Bookmark>::Iterator it = mBookmarks.begin();
222 for( ; it != mBookmarks.end(); ++it ) 244 for( ; it != mBookmarks.end(); ++it )
223 if ( (*it).file == file ) { 245 if ( (*it).file == file ) {
224 bookm->removeItem( it.key() ); 246 bookm->removeItem( it.key() );
225 mBookmarks.remove( it ); 247 mBookmarks.remove( it );
226 break; 248 break;
227 } 249 }
228} 250}
diff --git a/core/apps/helpbrowser/helpbrowser.h b/core/apps/helpbrowser/helpbrowser.h
index 2f7153a..5f7e6b6 100644
--- a/core/apps/helpbrowser/helpbrowser.h
+++ b/core/apps/helpbrowser/helpbrowser.h
@@ -1,69 +1,69 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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#ifndef HELPWINDOW_H 21#ifndef HELPWINDOW_H
22#define HELPWINDOW_H 22#define HELPWINDOW_H
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29class QPopupMenu; 29class QPopupMenu;
30class QAction; 30class QAction;
31 31
32class HelpBrowser : public QMainWindow 32class HelpBrowser : public QMainWindow
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 HelpBrowser( QWidget* parent = 0, const char *name=0, WFlags f=0 ); 36 HelpBrowser( QWidget* parent = 0, const char *name=0, WFlags f=0 );
37 ~HelpBrowser(); 37 ~HelpBrowser();
38 38
39public slots: 39public slots:
40 void setDocument( const QString &doc ); 40 void setDocument( const QString &doc );
41 41
42private slots: 42private slots:
43 void appMessage(const QCString& msg, const QByteArray& data); 43 void appMessage(const QCString& msg, const QByteArray& data);
44 void textChanged(); 44 void textChanged();
45 45
46 void pathSelected( const QString & ); 46 void pathSelected( const QString & );
47 void bookmChosen( int ); 47 void bookmChosen( int );
48 void addBookmark(); 48 void addBookmark();
49 void removeBookmark(); 49 void removeBookmark();
50 50
51private: 51private:
52 void init( const QString & ); 52 void init( const QString & );
53 void readBookmarks(); 53 void readBookmarks();
54 54
55 QTextBrowser* browser; 55 QTextBrowser* browser;
56 QAction *backAction; 56 QAction *backAction;
57 QAction *forwardAction; 57 QAction *forwardAction;
58 QString selectedURL; 58 QString selectedURL;
59 struct Bookmark { 59 struct Bookmark {
60 QString name; 60 QString name;
61 QString file; 61 QString file;
62 }; 62 };
63 QMap<int, Bookmark> mBookmarks; 63 QMap<int, Bookmark> mBookmarks;
64 QMenuBar *menu; 64 QMenuBar *menu;
65 QPopupMenu *bookm; 65 QPopupMenu *bookm;
66}; 66};
67 67
68#endif 68#endif
69 69
diff --git a/core/apps/helpbrowser/helpbrowser.pro b/core/apps/helpbrowser/helpbrowser.pro
index 6bb43bd..3525b7e 100644
--- a/core/apps/helpbrowser/helpbrowser.pro
+++ b/core/apps/helpbrowser/helpbrowser.pro
@@ -1,33 +1,33 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = helpbrowser.h 4 HEADERS = helpbrowser.h magictextbrowser.h
5 SOURCES = helpbrowser.cpp \ 5 SOURCES = helpbrowser.cpp magictextbrowser.cpp \
6 main.cpp 6 main.cpp
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10 INTERFACES= 10 INTERFACES=
11TARGET = helpbrowser 11TARGET = helpbrowser
12TRANSLATIONS = ../../../i18n/de/helpbrowser.ts \ 12TRANSLATIONS = ../../../i18n/de/helpbrowser.ts \
13 ../../../i18n/nl/helpbrowser.ts \ 13 ../../../i18n/nl/helpbrowser.ts \
14 ../../../i18n/xx/helpbrowser.ts \ 14 ../../../i18n/xx/helpbrowser.ts \
15 ../../../i18n/en/helpbrowser.ts \ 15 ../../../i18n/en/helpbrowser.ts \
16 ../../../i18n/es/helpbrowser.ts \ 16 ../../../i18n/es/helpbrowser.ts \
17 ../../../i18n/fr/helpbrowser.ts \ 17 ../../../i18n/fr/helpbrowser.ts \
18 ../../../i18n/hu/helpbrowser.ts \ 18 ../../../i18n/hu/helpbrowser.ts \
19 ../../../i18n/ja/helpbrowser.ts \ 19 ../../../i18n/ja/helpbrowser.ts \
20 ../../../i18n/ko/helpbrowser.ts \ 20 ../../../i18n/ko/helpbrowser.ts \
21 ../../../i18n/no/helpbrowser.ts \ 21 ../../../i18n/no/helpbrowser.ts \
22 ../../../i18n/pl/helpbrowser.ts \ 22 ../../../i18n/pl/helpbrowser.ts \
23 ../../../i18n/pt/helpbrowser.ts \ 23 ../../../i18n/pt/helpbrowser.ts \
24 ../../../i18n/pt_BR/helpbrowser.ts \ 24 ../../../i18n/pt_BR/helpbrowser.ts \
25 ../../../i18n/sl/helpbrowser.ts \ 25 ../../../i18n/sl/helpbrowser.ts \
26 ../../../i18n/zh_CN/helpbrowser.ts \ 26 ../../../i18n/zh_CN/helpbrowser.ts \
27 ../../../i18n/it/helpbrowser.ts \ 27 ../../../i18n/it/helpbrowser.ts \
28 ../../../i18n/zh_TW/helpbrowser.ts \ 28 ../../../i18n/zh_TW/helpbrowser.ts \
29 ../../../i18n/da/helpbrowser.ts 29 ../../../i18n/da/helpbrowser.ts
30 30
31 31
32 32
33include ( $(OPIEDIR)/include.pro ) 33include ( $(OPIEDIR)/include.pro )
diff --git a/core/apps/helpbrowser/magictextbrowser.cpp b/core/apps/helpbrowser/magictextbrowser.cpp
new file mode 100644
index 0000000..8ce0325
--- a/dev/null
+++ b/core/apps/helpbrowser/magictextbrowser.cpp
@@ -0,0 +1,99 @@
1#include <qfile.h>
2#include <qstring.h>
3#include <qdragobject.h>
4#include <qregexp.h>
5
6/* need to get Global::helpPath() */
7#define QTOPIA_INTERNAL_LANGLIST
8
9#include <qtopia/global.h>
10#include <qtopia/mimetype.h>
11#include <qtopia/applnk.h>
12
13#include "magictextbrowser.h"
14
15
16
17MagicTextBrowser::MagicTextBrowser(QWidget* parent) :
18 QTextBrowser(parent){
19}
20
21void MagicTextBrowser::setSource( const QString& source ) {
22 QTextBrowser::setSource(source);
23 if ( magicQpe(source,"applications") || magicQpe(source,"games") || magicQpe(source,"settings") || magicQpe(source, "1Pim") ) // No tr
24 return;
25 if ( magicOpe(source, "applets") || magicOpe(source, "input") )
26 return;
27 // Just those are magic (for now). Could do CGI here,
28 // or in Qtopia's mime source factory.
29}
30
31bool MagicTextBrowser::magicQpe(const QString& source, const QString& name) {
32 if ( name+".html" == source || "help/"+name+".html" == source) {
33 QString fn = mimeSourceFactory()->makeAbsolute( source, context() );
34 const QMimeSource* m = mimeSourceFactory()->data( fn, context() );
35 if ( m ) {
36 QString txt;
37 if ( QTextDrag::decode(m,txt) ) {
38 QRegExp re("<qtopia-"+name+">.*</qtopia-"+name+">");
39 int start,len;
40 if ( (start=re.match(txt,0,&len))>=0 ) {
41 QString generated = generateQpe(name);
42 txt.replace(start,len,generated);
43 setText(txt);
44 return true;
45 }
46 }
47 }
48 }
49 return false;
50}
51bool MagicTextBrowser::magicOpe( const QString& source, const QString& name ) {
52 if ( name+".html" != source && "help/"+name+".html" != source) return false;
53
54 QString fn = mimeSourceFactory()->makeAbsolute( source, context() );
55 const QMimeSource* m = mimeSourceFactory()->data(fn, context() );
56 if (!m) return false;
57
58 QString txt;
59 if ( !QTextDrag::decode(m, txt ) ) return false;
60
61 QRegExp re("<opie-"+name+">.*</opie-"+name+">");
62 int start,len;
63 if ( (start=re.match(txt,0,&len))>=0 ) {
64 QString generated = generateOpe(name);
65 txt.replace(start,len,generated);
66 setText(txt);
67 return true;
68 }
69 return false;
70}
71QString MagicTextBrowser::generateOpe(const QString& name)const {
72 if ( name == QString::fromLatin1("applets") ) {
73 return QString::fromLatin1("<h3>No Applets found</h3>");
74 }else if ( name == QString::fromLatin1("input") ) {
75 return QString::fromLatin1("<h3>No input methods available</h3>");
76 }else
77 return QString::null;
78}
79
80QString MagicTextBrowser::generateQpe(const QString& name) const {
81 QString dir = MimeType::appsFolderName()+"/"+name[0].upper()+name.mid(1);
82 AppLnkSet lnkset(dir);
83 AppLnk* lnk;
84 QString r;
85 for (QListIterator<AppLnk> it(lnkset.children()); (lnk=it.current()); ++it) {
86 QString name = lnk->name();
87 QString icon = lnk->icon();
88 QString helpFile = lnk->exec()+".html";
89 QStringList helpPath = Global::helpPath();
90 bool helpExists = FALSE;
91 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it)
92 helpExists = QFile::exists( *it + "/" + helpFile );
93
94 if ( helpExists ) {
95 r += "<h3><a href="+helpFile+"><img src="+icon+">"+name+"</a></h3>\n";
96 }
97 }
98 return r;
99}
diff --git a/core/apps/helpbrowser/magictextbrowser.h b/core/apps/helpbrowser/magictextbrowser.h
new file mode 100644
index 0000000..ff91e68
--- a/dev/null
+++ b/core/apps/helpbrowser/magictextbrowser.h
@@ -0,0 +1,42 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2003 zecke
4**
5** This file is part of the Qtopia Environment.
6**
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16**
17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you.
19**
20**********************************************************************/
21#ifndef HELP_BROWSER_MAGIC_TEXT_BROWSER_H
22#define HELP_BROWSER_MAGIC_TEXT_BROWSER_H
23
24#include <qtextbrowser.h>
25
26class MagicTextBrowser : public QTextBrowser {
27public:
28 MagicTextBrowser(QWidget* parent);
29
30 void setSource( const QString& source );
31
32 /** honor QPE Attributes */
33 bool magicQpe(const QString& source, const QString& name);
34 /** honor OPIE Attributes */
35 bool magicOpe(const QString& source, const QString& name );
36private:
37
38 QString generateQpe(const QString& name) const;
39 QString generateOpe(const QString& name) const;
40};
41
42#endif
diff --git a/core/apps/helpbrowser/main.cpp b/core/apps/helpbrowser/main.cpp
index 1cb10b7..b1bea56 100644
--- a/core/apps/helpbrowser/main.cpp
+++ b/core/apps/helpbrowser/main.cpp
@@ -1,34 +1,33 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the 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 "helpbrowser.h" 21#include "helpbrowser.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
25int main( int argc, char ** argv ) 25int main( int argc, char ** argv )
26{ 26{
27 QPEApplication a( argc, argv ); 27 QPEApplication a( argc, argv );
28 28
29 HelpBrowser mw; 29 HelpBrowser mw;
30 mw.setCaption( HelpBrowser::tr("HelpBrowser") ); 30 a.showMainWidget( &mw );
31 a.showMainDocumentWidget( &mw );
32 31
33 return a.exec(); 32 return a.exec();
34} 33}
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 6f96574..1c95a97 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -316,892 +316,890 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
316 searchBarAction->setToggleAction(true); 316 searchBarAction->setToggleAction(true);
317 searchBarAction->addTo( advancedMenu); 317 searchBarAction->addTo( advancedMenu);
318 318
319 nAutoSave = new QAction( tr("Auto Save 5 min."), 319 nAutoSave = new QAction( tr("Auto Save 5 min."),
320 QString::null, 0, this, 0 ); 320 QString::null, 0, this, 0 );
321 connect( nAutoSave, SIGNAL( toggled(bool) ), 321 connect( nAutoSave, SIGNAL( toggled(bool) ),
322 this, SLOT( doTimer(bool) ) ); 322 this, SLOT( doTimer(bool) ) );
323 nAutoSave->setToggleAction(true); 323 nAutoSave->setToggleAction(true);
324 nAutoSave->addTo( advancedMenu); 324 nAutoSave->addTo( advancedMenu);
325 325
326 326
327 //font->insertSeparator(); 327 //font->insertSeparator();
328 328
329 //font->insertItem(tr("About"), this, SLOT( doAbout()) ); 329 //font->insertItem(tr("About"), this, SLOT( doAbout()) );
330 330
331 mb->insertItem( tr( "File" ), file ); 331 mb->insertItem( tr( "File" ), file );
332 mb->insertItem( tr( "Edit" ), edit ); 332 mb->insertItem( tr( "Edit" ), edit );
333 mb->insertItem( tr( "View" ), font ); 333 mb->insertItem( tr( "View" ), font );
334 334
335 searchBar = new QPEToolBar(this); 335 searchBar = new QPEToolBar(this);
336 addToolBar( searchBar, "Search", QMainWindow::Top, true ); 336 addToolBar( searchBar, "Search", QMainWindow::Top, true );
337 337
338 searchBar->setHorizontalStretchable( true ); 338 searchBar->setHorizontalStretchable( true );
339 339
340 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 340 searchEdit = new QLineEdit( searchBar, "searchEdit" );
341 searchBar->setStretchableWidget( searchEdit ); 341 searchBar->setStretchableWidget( searchEdit );
342 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 342 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
343 this, SLOT( search() ) ); 343 this, SLOT( search() ) );
344 344
345 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), 345 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
346 QString::null, 0, this, 0 ); 346 QString::null, 0, this, 0 );
347 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 347 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
348 a->addTo( searchBar ); 348 a->addTo( searchBar );
349 a->addTo( edit ); 349 a->addTo( edit );
350 350
351 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), 351 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
352 QString::null, 0, this, 0 ); 352 QString::null, 0, this, 0 );
353 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 353 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
354 a->addTo( searchBar ); 354 a->addTo( searchBar );
355 355
356 edit->insertSeparator(); 356 edit->insertSeparator();
357 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), 357 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
358 QString::null, 0, this, 0 ); 358 QString::null, 0, this, 0 );
359 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 359 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
360 a->addTo( edit ); 360 a->addTo( edit );
361 361
362 searchBar->hide(); 362 searchBar->hide();
363 363
364 editor = new QpeEditor( this ); 364 editor = new QpeEditor( this );
365 setCentralWidget( editor ); 365 setCentralWidget( editor );
366 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 366 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
367 connect( editor, SIGNAL( textChanged() ), 367 connect( editor, SIGNAL( textChanged() ),
368 this, SLOT( editorChanged() ) ); 368 this, SLOT( editorChanged() ) );
369 369
370 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 370 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
371 371
372 Config cfg("TextEdit"); 372 Config cfg("TextEdit");
373 cfg. setGroup ( "Font" ); 373 cfg. setGroup ( "Font" );
374 374
375 QFont defaultFont = editor-> font ( ); 375 QFont defaultFont = editor-> font ( );
376 376
377 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 377 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
378 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 378 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
379 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 379 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
380 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 380 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
381 381
382 defaultFont = QFont ( family, size, weight, italic ); 382 defaultFont = QFont ( family, size, weight, italic );
383 editor-> setFont ( defaultFont ); 383 editor-> setFont ( defaultFont );
384// updateCaption(); 384// updateCaption();
385 385
386 cfg.setGroup ( "View" ); 386 cfg.setGroup ( "View" );
387 387
388 promptExit = cfg.readBoolEntry ( "PromptExit", false ); 388 promptExit = cfg.readBoolEntry ( "PromptExit", false );
389 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 389 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
390 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 390 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
391 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 391 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
392 startWithNew = cfg.readBoolEntry ( "startNew", true); 392 startWithNew = cfg.readBoolEntry ( "startNew", true);
393 featureAutoSave = cfg.readBoolEntry( "autosave", false); 393 featureAutoSave = cfg.readBoolEntry( "autosave", false);
394 394
395 if(useSearchBar) searchBarAction->setOn(true); 395 if(useSearchBar) searchBarAction->setOn(true);
396 if(promptExit) nAdvanced->setOn( true ); 396 if(promptExit) nAdvanced->setOn( true );
397 if(openDesktop) desktopAction->setOn( true ); 397 if(openDesktop) desktopAction->setOn( true );
398 if(filePerms) filePermAction->setOn( true ); 398 if(filePerms) filePermAction->setOn( true );
399 if(startWithNew) nStart->setOn( true ); 399 if(startWithNew) nStart->setOn( true );
400 if(featureAutoSave) nAutoSave->setOn(true); 400 if(featureAutoSave) nAutoSave->setOn(true);
401 401
402// { 402// {
403// doTimer(true); 403// doTimer(true);
404// } 404// }
405 405
406 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 406 bool wrap = cfg. readBoolEntry ( "Wrap", true );
407 wa-> setOn ( wrap ); 407 wa-> setOn ( wrap );
408 setWordWrap ( wrap ); 408 setWordWrap ( wrap );
409 409
410///////////////// 410/////////////////
411 if( qApp->argc() > 1) { 411 if( qApp->argc() > 1) {
412 currentFileName=qApp->argv()[1]; 412 currentFileName=qApp->argv()[1];
413 413
414 QFileInfo fi(currentFileName); 414 QFileInfo fi(currentFileName);
415 415
416 if(fi.baseName().left(1) == "") { 416 if(fi.baseName().left(1) == "") {
417 openDotFile(currentFileName); 417 openDotFile(currentFileName);
418 } else { 418 } else {
419 openFile(currentFileName); 419 openFile(currentFileName);
420 } 420 }
421 } else { 421 } else {
422 edited1=false; 422 edited1=false;
423 openDotFile(""); 423 openDotFile("");
424 } 424 }
425 425
426 viewSelection = cfg.readNumEntry( "FileView", 0 ); 426 viewSelection = cfg.readNumEntry( "FileView", 0 );
427} 427}
428 428
429TextEdit::~TextEdit() { 429TextEdit::~TextEdit() {
430 qWarning("textedit d'tor"); 430 qWarning("textedit d'tor");
431 delete editor; 431 delete editor;
432} 432}
433 433
434void TextEdit::closeEvent(QCloseEvent *) { 434void TextEdit::closeEvent(QCloseEvent *) {
435 if( edited1 && promptExit) 435 if( edited1 && promptExit)
436 { 436 {
437 switch( savePrompt() ) 437 switch( savePrompt() )
438 { 438 {
439 case 1: 439 case 1:
440 { 440 {
441 saveAs(); 441 saveAs();
442 qApp->quit(); 442 qApp->quit();
443 } 443 }
444 break; 444 break;
445 445
446 case 2: 446 case 2:
447 { 447 {
448 qApp->quit(); 448 qApp->quit();
449 } 449 }
450 break; 450 break;
451 451
452 case -1: 452 case -1:
453 break; 453 break;
454 }; 454 };
455 } 455 }
456 else 456 else
457 qApp->quit(); 457 qApp->quit();
458 458
459} 459}
460 460
461void TextEdit::cleanUp() { 461void TextEdit::cleanUp() {
462 462
463 Config cfg ( "TextEdit" ); 463 Config cfg ( "TextEdit" );
464 cfg. setGroup ( "Font" ); 464 cfg. setGroup ( "Font" );
465 QFont f = editor->font(); 465 QFont f = editor->font();
466 cfg.writeEntry ( "Family", f. family ( )); 466 cfg.writeEntry ( "Family", f. family ( ));
467 cfg.writeEntry ( "Size", f. pointSize ( )); 467 cfg.writeEntry ( "Size", f. pointSize ( ));
468 cfg.writeEntry ( "Weight", f. weight ( )); 468 cfg.writeEntry ( "Weight", f. weight ( ));
469 cfg.writeEntry ( "Italic", f. italic ( )); 469 cfg.writeEntry ( "Italic", f. italic ( ));
470 470
471 cfg.setGroup ( "View" ); 471 cfg.setGroup ( "View" );
472 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 472 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
473 cfg.writeEntry ( "FileView", viewSelection ); 473 cfg.writeEntry ( "FileView", viewSelection );
474 474
475 cfg.writeEntry ( "PromptExit", promptExit ); 475 cfg.writeEntry ( "PromptExit", promptExit );
476 cfg.writeEntry ( "OpenDesktop", openDesktop ); 476 cfg.writeEntry ( "OpenDesktop", openDesktop );
477 cfg.writeEntry ( "FilePermissions", filePerms ); 477 cfg.writeEntry ( "FilePermissions", filePerms );
478 cfg.writeEntry ( "SearchBar", useSearchBar ); 478 cfg.writeEntry ( "SearchBar", useSearchBar );
479 cfg.writeEntry ( "startNew", startWithNew ); 479 cfg.writeEntry ( "startNew", startWithNew );
480 480
481} 481}
482 482
483 483
484void TextEdit::accept() { 484void TextEdit::accept() {
485 if( edited1) 485 if( edited1)
486 saveAs(); 486 saveAs();
487 qApp->quit(); 487 qApp->quit();
488} 488}
489 489
490void TextEdit::zoomIn() { 490void TextEdit::zoomIn() {
491 setFontSize(editor->font().pointSize()+1,false); 491 setFontSize(editor->font().pointSize()+1,false);
492} 492}
493 493
494void TextEdit::zoomOut() { 494void TextEdit::zoomOut() {
495 setFontSize(editor->font().pointSize()-1,true); 495 setFontSize(editor->font().pointSize()-1,true);
496} 496}
497 497
498 498
499void TextEdit::setFontSize(int sz, bool round_down_not_up) { 499void TextEdit::setFontSize(int sz, bool round_down_not_up) {
500 int s=10; 500 int s=10;
501 for (int i=0; i<nfontsizes; i++) { 501 for (int i=0; i<nfontsizes; i++) {
502 if ( fontsize[i] == sz ) { 502 if ( fontsize[i] == sz ) {
503 s = sz; 503 s = sz;
504 break; 504 break;
505 } else if ( round_down_not_up ) { 505 } else if ( round_down_not_up ) {
506 if ( fontsize[i] < sz ) 506 if ( fontsize[i] < sz )
507 s = fontsize[i]; 507 s = fontsize[i];
508 } else { 508 } else {
509 if ( fontsize[i] > sz ) { 509 if ( fontsize[i] > sz ) {
510 s = fontsize[i]; 510 s = fontsize[i];
511 break; 511 break;
512 } 512 }
513 } 513 }
514 } 514 }
515 515
516 QFont f = editor->font(); 516 QFont f = editor->font();
517 f.setPointSize(s); 517 f.setPointSize(s);
518 editor->setFont(f); 518 editor->setFont(f);
519 519
520 zin->setEnabled(s != fontsize[nfontsizes-1]); 520 zin->setEnabled(s != fontsize[nfontsizes-1]);
521 zout->setEnabled(s != fontsize[0]); 521 zout->setEnabled(s != fontsize[0]);
522} 522}
523 523
524void TextEdit::setBold(bool y) { 524void TextEdit::setBold(bool y) {
525 QFont f = editor->font(); 525 QFont f = editor->font();
526 f.setBold(y); 526 f.setBold(y);
527 editor->setFont(f); 527 editor->setFont(f);
528} 528}
529 529
530void TextEdit::setItalic(bool y) { 530void TextEdit::setItalic(bool y) {
531 QFont f = editor->font(); 531 QFont f = editor->font();
532 f.setItalic(y); 532 f.setItalic(y);
533 editor->setFont(f); 533 editor->setFont(f);
534} 534}
535 535
536void TextEdit::setWordWrap(bool y) { 536void TextEdit::setWordWrap(bool y) {
537 bool state = editor->edited(); 537 bool state = editor->edited();
538 QString captionStr = caption(); 538 QString captionStr = caption();
539 bool b1 = edited1; 539 bool b1 = edited1;
540 bool b2 = edited; 540 bool b2 = edited;
541 541
542 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 542 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
543 editor->setEdited( state ); 543 editor->setEdited( state );
544 edited1=b1; 544 edited1=b1;
545 edited=b2; 545 edited=b2;
546 setCaption(captionStr); 546 setCaption(captionStr);
547} 547}
548 548
549void TextEdit::setSearchBar(bool b) { 549void TextEdit::setSearchBar(bool b) {
550 useSearchBar=b; 550 useSearchBar=b;
551 Config cfg("TextEdit"); 551 Config cfg("TextEdit");
552 cfg.setGroup("View"); 552 cfg.setGroup("View");
553 cfg.writeEntry ( "SearchBar", b ); 553 cfg.writeEntry ( "SearchBar", b );
554 searchBarAction->setOn(b); 554 searchBarAction->setOn(b);
555 if(b) 555 if(b)
556 searchBar->show(); 556 searchBar->show();
557 else 557 else
558 searchBar->hide(); 558 searchBar->hide();
559 editor->setFocus(); 559 editor->setFocus();
560} 560}
561 561
562void TextEdit::fileNew() { 562void TextEdit::fileNew() {
563// if( !bFromDocView ) { 563// if( !bFromDocView ) {
564// saveAs(); 564// saveAs();
565// } 565// }
566 newFile(DocLnk()); 566 newFile(DocLnk());
567} 567}
568 568
569void TextEdit::fileOpen() { 569void TextEdit::fileOpen() {
570 Config cfg("TextEdit"); 570 Config cfg("TextEdit");
571 cfg. setGroup ( "View" ); 571 cfg. setGroup ( "View" );
572 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
573 QMap<QString, QStringList> map; 572 QMap<QString, QStringList> map;
574 map.insert(tr("All"), QStringList() ); 573 map.insert(tr("All"), QStringList() );
575 QStringList text; 574 QStringList text;
576 text << "text/*"; 575 text << "text/*";
577 map.insert(tr("Text"), text ); 576 map.insert(tr("Text"), text );
578 text << "*"; 577 text << "*";
579 map.insert(tr("All"), text ); 578 map.insert(tr("All"), text );
580 QString str = OFileDialog::getOpenFileName( 2, 579 QString str = OFileDialog::getOpenFileName( 2,
581 dir , 580 QString::null ,
582 QString::null, map); 581 QString::null, map);
583 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 582 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
584 { 583 {
585 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false));
586 openFile( str ); 584 openFile( str );
587 } 585 }
588 else 586 else
589 updateCaption(); 587 updateCaption();
590} 588}
591 589
592void TextEdit::doSearchBar() { 590void TextEdit::doSearchBar() {
593 if(!useSearchBar) 591 if(!useSearchBar)
594 searchBar->hide(); 592 searchBar->hide();
595 else 593 else
596 searchBar->show(); 594 searchBar->show();
597} 595}
598 596
599#if 0 597#if 0
600void TextEdit::slotFind() { 598void TextEdit::slotFind() {
601 FindDialog frmFind( tr("Text Editor"), this ); 599 FindDialog frmFind( tr("Text Editor"), this );
602 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
603 editor, SLOT(slotDoFind( const QString&,bool,bool))); 601 editor, SLOT(slotDoFind( const QString&,bool,bool)));
604 602
605 //case sensitive, backwards, [category] 603 //case sensitive, backwards, [category]
606 604
607 connect( editor, SIGNAL(notFound()), 605 connect( editor, SIGNAL(notFound()),
608 &frmFind, SLOT(slotNotFound()) ); 606 &frmFind, SLOT(slotNotFound()) );
609 connect( editor, SIGNAL(searchWrapped()), 607 connect( editor, SIGNAL(searchWrapped()),
610 &frmFind, SLOT(slotWrapAround()) ); 608 &frmFind, SLOT(slotWrapAround()) );
611 609
612 frmFind.exec(); 610 frmFind.exec();
613 611
614 612
615} 613}
616#endif 614#endif
617 615
618void TextEdit::fileRevert() { 616void TextEdit::fileRevert() {
619 clear(); 617 clear();
620 fileOpen(); 618 fileOpen();
621} 619}
622 620
623void TextEdit::editCut() { 621void TextEdit::editCut() {
624#ifndef QT_NO_CLIPBOARD 622#ifndef QT_NO_CLIPBOARD
625 editor->cut(); 623 editor->cut();
626#endif 624#endif
627} 625}
628 626
629void TextEdit::editCopy() { 627void TextEdit::editCopy() {
630#ifndef QT_NO_CLIPBOARD 628#ifndef QT_NO_CLIPBOARD
631 editor->copy(); 629 editor->copy();
632#endif 630#endif
633} 631}
634 632
635void TextEdit::editPaste() { 633void TextEdit::editPaste() {
636#ifndef QT_NO_CLIPBOARD 634#ifndef QT_NO_CLIPBOARD
637 editor->paste(); 635 editor->paste();
638#endif 636#endif
639} 637}
640 638
641void TextEdit::editFind() { 639void TextEdit::editFind() {
642 searchBar->show(); 640 searchBar->show();
643 searchEdit->setFocus(); 641 searchEdit->setFocus();
644} 642}
645 643
646void TextEdit::findNext() { 644void TextEdit::findNext() {
647 editor->find( searchEdit->text(), false, false ); 645 editor->find( searchEdit->text(), false, false );
648 646
649} 647}
650 648
651void TextEdit::findClose() { 649void TextEdit::findClose() {
652 searchBar->hide(); 650 searchBar->hide();
653} 651}
654 652
655void TextEdit::search() { 653void TextEdit::search() {
656 editor->find( searchEdit->text(), false, false ); 654 editor->find( searchEdit->text(), false, false );
657} 655}
658 656
659void TextEdit::newFile( const DocLnk &f ) { 657void TextEdit::newFile( const DocLnk &f ) {
660 DocLnk nf = f; 658 DocLnk nf = f;
661 nf.setType("text/plain"); 659 nf.setType("text/plain");
662 clear(); 660 clear();
663 setWState (WState_Reserved1 ); 661 setWState (WState_Reserved1 );
664 editor->setFocus(); 662 editor->setFocus();
665 doc = new DocLnk(nf); 663 doc = new DocLnk(nf);
666 currentFileName = "Unnamed"; 664 currentFileName = "Unnamed";
667 qDebug("newFile "+currentFileName); 665 qDebug("newFile "+currentFileName);
668 updateCaption( currentFileName); 666 updateCaption( currentFileName);
669// editor->setEdited( false); 667// editor->setEdited( false);
670} 668}
671 669
672void TextEdit::openDotFile( const QString &f ) { 670void TextEdit::openDotFile( const QString &f ) {
673 if(!currentFileName.isEmpty()) { 671 if(!currentFileName.isEmpty()) {
674 currentFileName=f; 672 currentFileName=f;
675 673
676 qDebug("openFile dotfile " + currentFileName); 674 qDebug("openFile dotfile " + currentFileName);
677 QString txt; 675 QString txt;
678 QFile file(f); 676 QFile file(f);
679 file.open(IO_ReadWrite); 677 file.open(IO_ReadWrite);
680 QTextStream t(&file); 678 QTextStream t(&file);
681 while ( !t.atEnd()) { 679 while ( !t.atEnd()) {
682 txt+=t.readLine()+"\n"; 680 txt+=t.readLine()+"\n";
683 } 681 }
684 editor->setText(txt); 682 editor->setText(txt);
685 editor->setEdited( false); 683 editor->setEdited( false);
686 edited1=false; 684 edited1=false;
687 edited=false; 685 edited=false;
688 686
689 687
690 } 688 }
691 updateCaption( currentFileName); 689 updateCaption( currentFileName);
692} 690}
693 691
694void TextEdit::openFile( const QString &f ) { 692void TextEdit::openFile( const QString &f ) {
695 qDebug("filename is "+ f); 693 qDebug("filename is "+ f);
696 QString filer; 694 QString filer;
697 QFileInfo fi( f); 695 QFileInfo fi( f);
698// bFromDocView = true; 696// bFromDocView = true;
699 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 697 if(f.find(".desktop",0,true) != -1 && !openDesktop )
700 { 698 {
701 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) 699 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
702 { 700 {
703 case 0: //desktop 701 case 0: //desktop
704 filer = f; 702 filer = f;
705 break; 703 break;
706 case 1: //linked 704 case 1: //linked
707 DocLnk sf(f); 705 DocLnk sf(f);
708 filer = sf.file(); 706 filer = sf.file();
709 break; 707 break;
710 }; 708 };
711 } 709 }
712 else if(fi.baseName().left(1) == "") 710 else if(fi.baseName().left(1) == "")
713 { 711 {
714 qDebug("opening dotfile"); 712 qDebug("opening dotfile");
715 currentFileName=f; 713 currentFileName=f;
716 openDotFile(currentFileName); 714 openDotFile(currentFileName);
717 return; 715 return;
718 } 716 }
719 else 717 else
720 { 718 {
721 DocLnk sf(f); 719 DocLnk sf(f);
722 filer = sf.file(); 720 filer = sf.file();
723 if(filer.right(1) == "/") 721 if(filer.right(1) == "/")
724 filer = f; 722 filer = f;
725 } 723 }
726 724
727 DocLnk nf; 725 DocLnk nf;
728 nf.setType("text/plain"); 726 nf.setType("text/plain");
729 nf.setFile(filer); 727 nf.setFile(filer);
730 currentFileName=filer; 728 currentFileName=filer;
731 729
732 nf.setName(fi.baseName()); 730 nf.setName(fi.baseName());
733 openFile(nf); 731 openFile(nf);
734 732
735 qDebug("openFile string "+currentFileName); 733 qDebug("openFile string "+currentFileName);
736 734
737 showEditTools(); 735 showEditTools();
738 // Show filename in caption 736 // Show filename in caption
739 QString name = filer; 737 QString name = filer;
740 int sep = name.findRev( '/' ); 738 int sep = name.findRev( '/' );
741 if ( sep > 0 ) 739 if ( sep > 0 )
742 name = name.mid( sep+1 ); 740 name = name.mid( sep+1 );
743 updateCaption( name ); 741 updateCaption( name );
744} 742}
745 743
746void TextEdit::openFile( const DocLnk &f ) { 744void TextEdit::openFile( const DocLnk &f ) {
747// clear(); 745// clear();
748// bFromDocView = true; 746// bFromDocView = true;
749 FileManager fm; 747 FileManager fm;
750 QString txt; 748 QString txt;
751 currentFileName=f.file(); 749 currentFileName=f.file();
752 qDebug("openFile doclnk " + currentFileName); 750 qDebug("openFile doclnk " + currentFileName);
753 if ( !fm.loadFile( f, txt ) ) { 751 if ( !fm.loadFile( f, txt ) ) {
754 // ####### could be a new file 752 // ####### could be a new file
755 qDebug( "Cannot open file" ); 753 qDebug( "Cannot open file" );
756 } 754 }
757// fileNew(); 755// fileNew();
758 if ( doc ) 756 if ( doc )
759 delete doc; 757 delete doc;
760 doc = new DocLnk(f); 758 doc = new DocLnk(f);
761 editor->setText(txt); 759 editor->setText(txt);
762 editor->setEdited( false); 760 editor->setEdited( false);
763 edited1=false; 761 edited1=false;
764 edited=false; 762 edited=false;
765 763
766 doc->setName(currentFileName); 764 doc->setName(currentFileName);
767 updateCaption(); 765 updateCaption();
768 setTimer(); 766 setTimer();
769} 767}
770 768
771void TextEdit::showEditTools() { 769void TextEdit::showEditTools() {
772 menu->show(); 770 menu->show();
773 editBar->show(); 771 editBar->show();
774 if(!useSearchBar) 772 if(!useSearchBar)
775 searchBar->hide(); 773 searchBar->hide();
776 else 774 else
777 searchBar->show(); 775 searchBar->show();
778 setWState (WState_Reserved1 ); 776 setWState (WState_Reserved1 );
779} 777}
780 778
781/*! 779/*!
782 unprompted save */ 780 unprompted save */
783bool TextEdit::save() { 781bool TextEdit::save() {
784 qDebug("saveAsFile " + currentFileName); 782 qDebug("saveAsFile " + currentFileName);
785 if(currentFileName.isEmpty()) { 783 if(currentFileName.isEmpty()) {
786 saveAs(); 784 saveAs();
787 return false; 785 return false;
788 } 786 }
789 787
790 QString file = doc->file(); 788 QString file = doc->file();
791 qDebug("saver file "+file); 789 qDebug("saver file "+file);
792 QString name= doc->name(); 790 QString name= doc->name();
793 qDebug("File named "+name); 791 qDebug("File named "+name);
794 QString rt = editor->text(); 792 QString rt = editor->text();
795 if( !rt.isEmpty() ) { 793 if( !rt.isEmpty() ) {
796 if(name.isEmpty()) { 794 if(name.isEmpty()) {
797 saveAs(); 795 saveAs();
798 } else { 796 } else {
799 currentFileName= name ; 797 currentFileName= name ;
800 qDebug("saveFile "+currentFileName); 798 qDebug("saveFile "+currentFileName);
801 799
802 struct stat buf; 800 struct stat buf;
803 mode_t mode; 801 mode_t mode;
804 stat(file.latin1(), &buf); 802 stat(file.latin1(), &buf);
805 mode = buf.st_mode; 803 mode = buf.st_mode;
806 804
807 if(!fileIs) { 805 if(!fileIs) {
808 doc->setName( name); 806 doc->setName( name);
809 FileManager fm; 807 FileManager fm;
810 if ( !fm.saveFile( *doc, rt ) ) { 808 if ( !fm.saveFile( *doc, rt ) ) {
811 return false; 809 return false;
812 } 810 }
813 } else { 811 } else {
814 qDebug("regular save file"); 812 qDebug("regular save file");
815 QFile f(file); 813 QFile f(file);
816 if( f.open(IO_WriteOnly)) { 814 if( f.open(IO_WriteOnly)) {
817 QCString crt = rt.utf8(); 815 QCString crt = rt.utf8();
818 f.writeBlock(crt,crt.length()); 816 f.writeBlock(crt,crt.length());
819 } else { 817 } else {
820 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 818 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
821 return false; 819 return false;
822 } 820 }
823 821
824 } 822 }
825 editor->setEdited( false); 823 editor->setEdited( false);
826 edited1=false; 824 edited1=false;
827 edited=false; 825 edited=false;
828 if(caption().left(1)=="*") 826 if(caption().left(1)=="*")
829 setCaption(caption().right(caption().length()-1)); 827 setCaption(caption().right(caption().length()-1));
830 828
831 829
832 chmod( file.latin1(), mode); 830 chmod( file.latin1(), mode);
833 } 831 }
834 return true; 832 return true;
835 } 833 }
836 return false; 834 return false;
837} 835}
838 836
839/*! 837/*!
840 prompted save */ 838 prompted save */
841bool TextEdit::saveAs() { 839bool TextEdit::saveAs() {
842 840
843 if(caption() == tr("Text Editor")) 841 if(caption() == tr("Text Editor"))
844 return false; 842 return false;
845 qDebug("saveAsFile " + currentFileName); 843 qDebug("saveAsFile " + currentFileName);
846 // case of nothing to save... 844 // case of nothing to save...
847// if ( !doc && !currentFileName.isEmpty()) { 845// if ( !doc && !currentFileName.isEmpty()) {
848// //|| !bFromDocView) 846// //|| !bFromDocView)
849// qDebug("no doc"); 847// qDebug("no doc");
850// return true; 848// return true;
851// } 849// }
852// if ( !editor->edited() ) { 850// if ( !editor->edited() ) {
853// delete doc; 851// delete doc;
854// doc = 0; 852// doc = 0;
855// return true; 853// return true;
856// } 854// }
857 855
858 QString rt = editor->text(); 856 QString rt = editor->text();
859 qDebug(currentFileName); 857 qDebug(currentFileName);
860 858
861 if( currentFileName.isEmpty() 859 if( currentFileName.isEmpty()
862 || currentFileName == tr("Unnamed") 860 || currentFileName == tr("Unnamed")
863 || currentFileName == tr("Text Editor")) { 861 || currentFileName == tr("Text Editor")) {
864 qDebug("do silly TT filename thing"); 862 qDebug("do silly TT filename thing");
865// if ( doc && doc->name().isEmpty() ) { 863// if ( doc && doc->name().isEmpty() ) {
866 QString pt = rt.simplifyWhiteSpace(); 864 QString pt = rt.simplifyWhiteSpace();
867 int i = pt.find( ' ' ); 865 int i = pt.find( ' ' );
868 QString docname = pt; 866 QString docname = pt;
869 if ( i > 0 ) 867 if ( i > 0 )
870 docname = pt.left( i ); 868 docname = pt.left( i );
871 // remove "." at the beginning 869 // remove "." at the beginning
872 while( docname.startsWith( "." ) ) 870 while( docname.startsWith( "." ) )
873 docname = docname.mid( 1 ); 871 docname = docname.mid( 1 );
874 docname.replace( QRegExp("/"), "_" ); 872 docname.replace( QRegExp("/"), "_" );
875 // cut the length. filenames longer than that 873 // cut the length. filenames longer than that
876 //don't make sense and something goes wrong when they get too long. 874 //don't make sense and something goes wrong when they get too long.
877 if ( docname.length() > 40 ) 875 if ( docname.length() > 40 )
878 docname = docname.left(40); 876 docname = docname.left(40);
879 if ( docname.isEmpty() ) 877 if ( docname.isEmpty() )
880 docname = tr("Unnamed"); 878 docname = tr("Unnamed");
881 if(doc) doc->setName(docname); 879 if(doc) doc->setName(docname);
882 currentFileName=docname; 880 currentFileName=docname;
883// } 881// }
884// else 882// else
885// qDebug("hmmmmmm"); 883// qDebug("hmmmmmm");
886 } 884 }
887 885
888 886
889 QMap<QString, QStringList> map; 887 QMap<QString, QStringList> map;
890 map.insert(tr("All"), QStringList() ); 888 map.insert(tr("All"), QStringList() );
891 QStringList text; 889 QStringList text;
892 text << "text/*"; 890 text << "text/*";
893 map.insert(tr("Text"), text ); 891 map.insert(tr("Text"), text );
894 text << "*"; 892 text << "*";
895 map.insert(tr("All"), text ); 893 map.insert(tr("All"), text );
896 894
897 QFileInfo cuFi( currentFileName); 895 QFileInfo cuFi( currentFileName);
898 QString filee = cuFi.fileName(); 896 QString filee = cuFi.fileName();
899 QString dire = cuFi.dirPath(); 897 QString dire = cuFi.dirPath();
900 if(dire==".") 898 if(dire==".")
901 dire = QPEApplication::documentDir(); 899 dire = QPEApplication::documentDir();
902 QString str; 900 QString str;
903 if( !featureAutoSave) 901 if( !featureAutoSave)
904 { 902 {
905 str = OFileDialog::getSaveFileName( 2, 903 str = OFileDialog::getSaveFileName( 2,
906 dire, 904 dire,
907 filee, map); 905 filee, map);
908 } 906 }
909 else 907 else
910 str=currentFileName; 908 str=currentFileName;
911 if(!str.isEmpty()) { 909 if(!str.isEmpty()) {
912 QString fileNm=str; 910 QString fileNm=str;
913 911
914 qDebug("saving filename "+fileNm); 912 qDebug("saving filename "+fileNm);
915 QFileInfo fi(fileNm); 913 QFileInfo fi(fileNm);
916 currentFileName=fi.fileName(); 914 currentFileName=fi.fileName();
917 if(doc) 915 if(doc)
918// QString file = doc->file(); 916// QString file = doc->file();
919// doc->removeFiles(); 917// doc->removeFiles();
920 delete doc; 918 delete doc;
921 DocLnk nf; 919 DocLnk nf;
922 nf.setType("text/plain"); 920 nf.setType("text/plain");
923 nf.setFile( fileNm); 921 nf.setFile( fileNm);
924 doc = new DocLnk(nf); 922 doc = new DocLnk(nf);
925// editor->setText(rt); 923// editor->setText(rt);
926 qDebug("Saving file as "+currentFileName); 924 qDebug("Saving file as "+currentFileName);
927 doc->setName( currentFileName); 925 doc->setName( currentFileName);
928 updateCaption( currentFileName); 926 updateCaption( currentFileName);
929 927
930 FileManager fm; 928 FileManager fm;
931 if ( !fm.saveFile( *doc, rt ) ) { 929 if ( !fm.saveFile( *doc, rt ) ) {
932 return false; 930 return false;
933 } 931 }
934 932
935 if( filePerms ) { 933 if( filePerms ) {
936 filePermissions *filePerm; 934 filePermissions *filePerm;
937 filePerm = new filePermissions(this, 935 filePerm = new filePermissions(this,
938 tr("Permissions"),true, 936 tr("Permissions"),true,
939 0,(const QString &)fileNm); 937 0,(const QString &)fileNm);
940 filePerm->showMaximized(); 938 filePerm->showMaximized();
941 filePerm->exec(); 939 filePerm->exec();
942 940
943 if( filePerm) 941 if( filePerm)
944 delete filePerm; 942 delete filePerm;
945 } 943 }
946// } 944// }
947 editor->setEdited( false); 945 editor->setEdited( false);
948 edited1 = false; 946 edited1 = false;
949 edited = false; 947 edited = false;
950 if(caption().left(1)=="*") 948 if(caption().left(1)=="*")
951 setCaption(caption().right(caption().length()-1)); 949 setCaption(caption().right(caption().length()-1));
952 950
953 return true; 951 return true;
954 } 952 }
955 qDebug("returning false"); 953 qDebug("returning false");
956 return false; 954 return false;
957} //end saveAs 955} //end saveAs
958 956
959void TextEdit::clear() { 957void TextEdit::clear() {
960 delete doc; 958 delete doc;
961 doc = 0; 959 doc = 0;
962 editor->clear(); 960 editor->clear();
963} 961}
964 962
965void TextEdit::updateCaption( const QString &name ) { 963void TextEdit::updateCaption( const QString &name ) {
966 964
967 if ( name.isEmpty() ) 965 if ( name.isEmpty() )
968 setCaption( tr("Text Editor") ); 966 setCaption( tr("Text Editor") );
969 else { 967 else {
970 QString s = name; 968 QString s = name;
971 if ( s.isNull() ) 969 if ( s.isNull() )
972 s = doc->name(); 970 s = doc->name();
973 if ( s.isEmpty() ) { 971 if ( s.isEmpty() ) {
974 s = tr( "Unnamed" ); 972 s = tr( "Unnamed" );
975 currentFileName=s; 973 currentFileName=s;
976 } 974 }
977// if(s.left(1) == "/") 975// if(s.left(1) == "/")
978// s = s.right(s.length()-1); 976// s = s.right(s.length()-1);
979 setCaption( s + " - " + tr("Text Editor") ); 977 setCaption( tr("%1 - Text Editor").arg( s ) );
980 } 978 }
981} 979}
982 980
983void TextEdit::setDocument(const QString& fileref) { 981void TextEdit::setDocument(const QString& fileref) {
984 if(fileref != "Unnamed") { 982 if(fileref != "Unnamed") {
985 currentFileName=fileref; 983 currentFileName=fileref;
986 qDebug("setDocument"); 984 qDebug("setDocument");
987 QFileInfo fi(currentFileName); 985 QFileInfo fi(currentFileName);
988 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 986 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
989 if( (fi.baseName().left(1)).isEmpty() ) { 987 if( (fi.baseName().left(1)).isEmpty() ) {
990 openDotFile(currentFileName); 988 openDotFile(currentFileName);
991 989
992 } else { 990 } else {
993 qDebug("setDoc open"); 991 qDebug("setDoc open");
994 bFromDocView = true; 992 bFromDocView = true;
995 openFile(fileref); 993 openFile(fileref);
996 editor->setEdited(true); 994 editor->setEdited(true);
997 edited1=false; 995 edited1=false;
998 edited=true; 996 edited=true;
999 // fromSetDocument=false; 997 // fromSetDocument=false;
1000 // doSearchBar(); 998 // doSearchBar();
1001 } 999 }
1002 } 1000 }
1003 updateCaption( currentFileName); 1001 updateCaption( currentFileName);
1004} 1002}
1005 1003
1006void TextEdit::changeFont() { 1004void TextEdit::changeFont() {
1007 QDialog *d = new QDialog ( this, "FontDialog", true ); 1005 QDialog *d = new QDialog ( this, "FontDialog", true );
1008 d-> setCaption ( tr( "Choose font" )); 1006 d-> setCaption ( tr( "Choose font" ));
1009 QBoxLayout *lay = new QVBoxLayout ( d ); 1007 QBoxLayout *lay = new QVBoxLayout ( d );
1010 OFontSelector *ofs = new OFontSelector ( true, d ); 1008 OFontSelector *ofs = new OFontSelector ( true, d );
1011 lay-> addWidget ( ofs ); 1009 lay-> addWidget ( ofs );
1012 ofs-> setSelectedFont ( editor-> font ( )); 1010 ofs-> setSelectedFont ( editor-> font ( ));
1013 1011
1014 d-> showMaximized ( ); 1012 d-> showMaximized ( );
1015 if ( d-> exec ( ) == QDialog::Accepted ) 1013 if ( d-> exec ( ) == QDialog::Accepted )
1016 editor-> setFont ( ofs-> selectedFont ( )); 1014 editor-> setFont ( ofs-> selectedFont ( ));
1017 delete d; 1015 delete d;
1018 1016
1019} 1017}
1020 1018
1021void TextEdit::editDelete() { 1019void TextEdit::editDelete() {
1022 switch ( QMessageBox::warning(this,tr("Text Editor"), 1020 switch ( QMessageBox::warning(this,tr("Text Editor"),
1023 tr("Do you really want<BR>to <B>delete</B> " 1021 tr("Do you really want<BR>to <B>delete</B> "
1024 "the current file\nfrom the disk?<BR>This is " 1022 "the current file\nfrom the disk?<BR>This is "
1025 "<B>irreversable!!</B>"), 1023 "<B>irreversable!</B>"),
1026 tr("Yes"),tr("No"),0,0,1) ) { 1024 tr("Yes"),tr("No"),0,0,1) ) {
1027 case 0: 1025 case 0:
1028 if(doc) { 1026 if(doc) {
1029 doc->removeFiles(); 1027 doc->removeFiles();
1030 clear(); 1028 clear();
1031 setCaption( tr("Text Editor") ); 1029 setCaption( tr("Text Editor") );
1032 } 1030 }
1033 break; 1031 break;
1034 case 1: 1032 case 1:
1035 // exit 1033 // exit
1036 break; 1034 break;
1037 }; 1035 };
1038} 1036}
1039 1037
1040void TextEdit::changeStartConfig( bool b ) { 1038void TextEdit::changeStartConfig( bool b ) {
1041 startWithNew=b; 1039 startWithNew=b;
1042 Config cfg("TextEdit"); 1040 Config cfg("TextEdit");
1043 cfg.setGroup("View"); 1041 cfg.setGroup("View");
1044 cfg.writeEntry("startNew",b); 1042 cfg.writeEntry("startNew",b);
1045 update(); 1043 update();
1046} 1044}
1047 1045
1048void TextEdit::editorChanged() { 1046void TextEdit::editorChanged() {
1049// qDebug("editor changed"); 1047// qDebug("editor changed");
1050 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1048 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1051 setCaption( "*"+caption()); 1049 setCaption( "*"+caption());
1052 edited1=true; 1050 edited1=true;
1053 } 1051 }
1054 edited=true; 1052 edited=true;
1055} 1053}
1056 1054
1057void TextEdit::receive(const QCString&msg, const QByteArray &) { 1055void TextEdit::receive(const QCString&msg, const QByteArray &) {
1058 qDebug("QCop "+msg); 1056 qDebug("QCop "+msg);
1059 if ( msg == "setDocument(QString)" ) { 1057 if ( msg == "setDocument(QString)" ) {
1060 qDebug("bugger all"); 1058 qDebug("bugger all");
1061 1059
1062 } 1060 }
1063 1061
1064} 1062}
1065 1063
1066void TextEdit::doAbout() { 1064void TextEdit::doAbout() {
1067 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1065 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1068 "2000 Trolltech AS, and<BR>" 1066 "2000 Trolltech AS, and<BR>"
1069 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1067 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1070 "and is licensed under the GPL")); 1068 "and is licensed under the GPL"));
1071} 1069}
1072 1070
1073void TextEdit::doPrompt(bool b) { 1071void TextEdit::doPrompt(bool b) {
1074 promptExit=b; 1072 promptExit=b;
1075 Config cfg("TextEdit"); 1073 Config cfg("TextEdit");
1076 cfg.setGroup ( "View" ); 1074 cfg.setGroup ( "View" );
1077 cfg.writeEntry ( "PromptExit", b); 1075 cfg.writeEntry ( "PromptExit", b);
1078} 1076}
1079 1077
1080void TextEdit::doDesktop(bool b) { 1078void TextEdit::doDesktop(bool b) {
1081 openDesktop=b; 1079 openDesktop=b;
1082 Config cfg("TextEdit"); 1080 Config cfg("TextEdit");
1083 cfg.setGroup ( "View" ); 1081 cfg.setGroup ( "View" );
1084 cfg.writeEntry ( "OpenDesktop", b); 1082 cfg.writeEntry ( "OpenDesktop", b);
1085} 1083}
1086 1084
1087void TextEdit::doFilePerms(bool b) { 1085void TextEdit::doFilePerms(bool b) {
1088 filePerms=b; 1086 filePerms=b;
1089 Config cfg("TextEdit"); 1087 Config cfg("TextEdit");
1090 cfg.setGroup ( "View" ); 1088 cfg.setGroup ( "View" );
1091 cfg.writeEntry ( "FilePermissions", b); 1089 cfg.writeEntry ( "FilePermissions", b);
1092} 1090}
1093 1091
1094void TextEdit::editPasteTimeDate() { 1092void TextEdit::editPasteTimeDate() {
1095#ifndef QT_NO_CLIPBOARD 1093#ifndef QT_NO_CLIPBOARD
1096 QClipboard *cb = QApplication::clipboard(); 1094 QClipboard *cb = QApplication::clipboard();
1097 QDateTime dt = QDateTime::currentDateTime(); 1095 QDateTime dt = QDateTime::currentDateTime();
1098 cb->setText( dt.toString()); 1096 cb->setText( dt.toString());
1099 editor->paste(); 1097 editor->paste();
1100#endif 1098#endif
1101} 1099}
1102 1100
1103int TextEdit::savePrompt() 1101int TextEdit::savePrompt()
1104{ 1102{
1105 switch( QMessageBox::information( 0, (tr("Textedit")), 1103 switch( QMessageBox::information( 0, (tr("Textedit")),
1106 (tr("Textedit detected\n" 1104 (tr("Textedit detected\n"
1107 "you have unsaved changes\n" 1105 "you have unsaved changes\n"
1108 "Go ahead and save?\n")), 1106 "Go ahead and save?\n")),
1109 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1107 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1110 { 1108 {
1111 case 0: 1109 case 0:
1112 { 1110 {
1113 return 1; 1111 return 1;
1114 } 1112 }
1115 break; 1113 break;
1116 1114
1117 case 1: 1115 case 1:
1118 { 1116 {
1119 return 2; 1117 return 2;
1120 } 1118 }
1121 break; 1119 break;
1122 1120
1123 case 2: 1121 case 2:
1124 { 1122 {
1125 return -1; 1123 return -1;
1126 } 1124 }
1127 break; 1125 break;
1128 }; 1126 };
1129 1127
1130 return 0; 1128 return 0;
1131} 1129}
1132 1130
1133void TextEdit::timerCrank() 1131void TextEdit::timerCrank()
1134{ 1132{
1135 if(featureAutoSave && edited1) 1133 if(featureAutoSave && edited1)
1136 { 1134 {
1137 if(currentFileName.isEmpty()) 1135 if(currentFileName.isEmpty())
1138 { 1136 {
1139 currentFileName = QDir::homeDirPath()+"/textedit.tmp"; 1137 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1140 saveAs(); 1138 saveAs();
1141 } 1139 }
1142 else 1140 else
1143 { 1141 {
1144// qDebug("autosave"); 1142// qDebug("autosave");
1145 save(); 1143 save();
1146 } 1144 }
1147 setTimer(); 1145 setTimer();
1148 } 1146 }
1149} 1147}
1150 1148
1151void TextEdit::doTimer(bool b) 1149void TextEdit::doTimer(bool b)
1152{ 1150{
1153 Config cfg("TextEdit"); 1151 Config cfg("TextEdit");
1154 cfg.setGroup ( "View" ); 1152 cfg.setGroup ( "View" );
1155 cfg.writeEntry ( "autosave", b); 1153 cfg.writeEntry ( "autosave", b);
1156 featureAutoSave = b; 1154 featureAutoSave = b;
1157 nAutoSave->setOn(b); 1155 nAutoSave->setOn(b);
1158 if(b) 1156 if(b)
1159 { 1157 {
1160// qDebug("doTimer true"); 1158// qDebug("doTimer true");
1161 setTimer(); 1159 setTimer();
1162 } 1160 }
1163// else 1161// else
1164// qDebug("doTimer false"); 1162// qDebug("doTimer false");
1165} 1163}
1166 1164
1167void TextEdit::setTimer() 1165void TextEdit::setTimer()
1168{ 1166{
1169if(featureAutoSave) 1167if(featureAutoSave)
1170 { 1168 {
1171// qDebug("setting autosave"); 1169// qDebug("setting autosave");
1172 QTimer *timer = new QTimer(this ); 1170 QTimer *timer = new QTimer(this );
1173 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1171 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1174 timer->start( 300000, true); //5 minutes 1172 timer->start( 300000, true); //5 minutes
1175 } 1173 }
1176} 1174}
1177 1175
1178void TextEdit::gotoLine() { 1176void TextEdit::gotoLine() {
1179 if( editor->length() < 1) 1177 if( editor->length() < 1)
1180 return; 1178 return;
1181 QWidget *d = QApplication::desktop(); 1179 QWidget *d = QApplication::desktop();
1182 gotoEdit = new QLineEdit( 0, "Goto line"); 1180 gotoEdit = new QLineEdit( 0, "Goto line");
1183 1181
1184 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); 1182 gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
1185 gotoEdit->setFrame(true); 1183 gotoEdit->setFrame(true);
1186 gotoEdit->show(); 1184 gotoEdit->show();
1187 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); 1185 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
1188} 1186}
1189 1187
1190void TextEdit::doGoto() { 1188void TextEdit::doGoto() {
1191 QString number = gotoEdit->text(); 1189 QString number = gotoEdit->text();
1192 gotoEdit->hide(); 1190 gotoEdit->hide();
1193 1191
1194 if(gotoEdit) { 1192 if(gotoEdit) {
1195 delete gotoEdit; 1193 delete gotoEdit;
1196 gotoEdit = 0; 1194 gotoEdit = 0;
1197 } 1195 }
1198 1196
1199 bool ok; 1197 bool ok;
1200 int lineNumber = number.toInt(&ok, 10); 1198 int lineNumber = number.toInt(&ok, 10);
1201 if( editor->numLines() < lineNumber) 1199 if( editor->numLines() < lineNumber)
1202 QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); 1200 QMessageBox::message(tr("Text Edit"),tr("Not enough lines"));
1203 else 1201 else
1204 { 1202 {
1205 editor->setCursorPosition(lineNumber, 0, false); 1203 editor->setCursorPosition(lineNumber, 0, false);
1206 } 1204 }
1207} 1205}
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index d95a59b..7dcb5f6 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,369 +1,385 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#define _GNU_SOURCE 28#define _GNU_SOURCE
29 29
30#include <sys/types.h> 30#include <sys/types.h>
31#include <time.h> 31#include <time.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/resource.h> 33#include <sys/resource.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <syslog.h> 35#include <syslog.h>
36#include <sys/wait.h> 36#include <sys/wait.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <signal.h> 39#include <signal.h>
40#include <getopt.h> 40#include <getopt.h>
41#include <string.h> 41#include <string.h>
42 42
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45#include <qpe/qpestyle.h> 45#include <qpe/qpestyle.h>
46#include <qpe/power.h> 46#include <qpe/power.h>
47#include <qpe/config.h> 47#include <qpe/config.h>
48 48
49#include <opie/odevice.h> 49#include <opie/odevice.h>
50 50
51#include <qwindowsystem_qws.h> 51#include <qwindowsystem_qws.h>
52#include <qwsmouse_qws.h> 52#include <qwsmouse_qws.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qlabel.h> 54#include <qlabel.h>
55#include <qtimer.h> 55#include <qtimer.h>
56#include <qfile.h> 56#include <qfile.h>
57#include <qtextstream.h>
57 58
58#include "loginapplication.h" 59#include "loginapplication.h"
59#include "loginwindowimpl.h" 60#include "loginwindowimpl.h"
60#include "calibrate.h" 61#include "calibrate.h"
61 62
62using namespace Opie; 63using namespace Opie;
63 64
64int login_main ( int argc, char **argv, pid_t ppid ); 65int login_main ( int argc, char **argv, pid_t ppid );
65void sigterm ( int sig ); 66void sigterm ( int sig );
66void sigint ( int sig ); 67void sigint ( int sig );
67void exit_closelog ( ); 68void exit_closelog ( );
68 69
69static struct option long_options [] = { 70static struct option long_options [] = {
70 { "autologin", 1, 0, 'a' }, 71 { "autologin", 1, 0, 'a' },
71 { 0, 0, 0, 0 } 72 { 0, 0, 0, 0 }
72}; 73};
73 74
74 75
75int main ( int argc, char **argv ) 76int main ( int argc, char **argv )
76{ 77{
78 int userExited = 0;
77 pid_t ppid = ::getpid ( ); 79 pid_t ppid = ::getpid ( );
78 80
79 if ( ::geteuid ( ) != 0 ) { 81 if ( ::geteuid ( ) != 0 ) {
80 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 82 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
81 return 1; 83 return 1;
82 } 84 }
83 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 85 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
84 ::setuid ( 0 ); // messes up things like config files 86 ::setuid ( 0 ); // messes up things like config files
85 87
86 char *autolog = 0; 88 char *autolog = 0;
87 int c; 89 int c;
88 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { 90 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
89 switch ( c ) { 91 switch ( c ) {
90 case 'a': 92 case 'a':
91 autolog = optarg; 93 autolog = optarg;
92 break; 94 break;
93 default: 95 default:
94 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); 96 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
95 return 2; 97 return 2;
96 } 98 }
97 } 99 }
98 100
99 //struct rlimit rl; 101 //struct rlimit rl;
100 //::getrlimit ( RLIMIT_NOFILE, &rl ); 102 //::getrlimit ( RLIMIT_NOFILE, &rl );
101 103
102 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 104 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
103 // ::close ( i ); 105 // ::close ( i );
104 106
105 ::setpgid ( 0, 0 ); 107 ::setpgid ( 0, 0 );
106 ::setsid ( ); 108 ::setsid ( );
107 109
108 ::signal ( SIGTERM, sigterm ); 110 ::signal ( SIGTERM, sigterm );
109 ::signal ( SIGINT, sigterm ); 111 ::signal ( SIGINT, sigterm );
110 112
111 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); 113 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV );
112 ::atexit ( exit_closelog ); 114 ::atexit ( exit_closelog );
113 115
114 while ( true ) { 116 while ( true ) {
115 pid_t child = ::fork ( ); 117 pid_t child = ::fork ( );
116 118
117 if ( child < 0 ) { 119 if ( child < 0 ) {
118 ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); 120 ::syslog ( LOG_ERR, "Could not fork GUI process\n" );
119 break; 121 break;
120 } 122 }
121 else if ( child > 0 ) { 123 else if ( child > 0 ) {
122 int status = 0; 124 int status = 0;
123 time_t started = ::time ( 0 ); 125 time_t started = ::time ( 0 );
124 126
125 while ( ::waitpid ( child, &status, 0 ) < 0 ) { } 127 while ( ::waitpid ( child, &status, 0 ) < 0 ) { }
126 128
127 LoginApplication::logout ( ); 129 LoginApplication::logout ( );
128 130
129 if (( ::time ( 0 ) - started ) < 3 ) { 131 if (( ::time ( 0 ) - started ) < 3 ) {
130 if ( autolog ) { 132 if ( autolog ) {
131 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); 133 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" );
132 autolog = 0; 134 autolog = 0;
133 } 135 }
134 else { 136 else {
135 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); 137 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" );
136 break; 138 break;
137 } 139 }
138 } 140 }
139 int killedbysig = 0; 141 int killedbysig = 0;
142 userExited=0;
143 if (WIFEXITED(status)!=0 ) {
144 if (WEXITSTATUS(status)==137) {
145 userExited=1;
146 }
147 }
140 148
141 if ( WIFSIGNALED( status )) { 149 if ( WIFSIGNALED( status )) {
142 switch ( WTERMSIG( status )) { 150 switch ( WTERMSIG( status )) {
143 case SIGINT :
144 case SIGTERM: 151 case SIGTERM:
152 case SIGINT :
145 case SIGKILL: 153 case SIGKILL:
146 break; 154 break;
147 155
148 default : 156 default :
149 killedbysig = WTERMSIG( status ); 157 killedbysig = WTERMSIG( status );
150 break; 158 break;
151 } 159 }
152 } 160 }
153 if ( killedbysig ) { // qpe was killed by an uncaught signal 161 if ( killedbysig ) { // qpe was killed by an uncaught signal
154 qApp = 0; 162 qApp = 0;
155 163
156 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); 164 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig );
157 165
158 QWSServer::setDesktopBackground ( QImage ( )); 166 QWSServer::setDesktopBackground ( QImage ( ));
159 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 167 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
160 app-> setFont ( QFont ( "Helvetica", 10 )); 168 app-> setFont ( QFont ( "Helvetica", 10 ));
161 app-> setStyle ( new QPEStyle ( )); 169 app-> setStyle ( new QPEStyle ( ));
162 170
163 const char *sig = ::strsignal ( killedbysig ); 171 const char *sig = ::strsignal ( killedbysig );
164 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 172 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
165 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 173 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
166 l-> setAlignment ( Qt::AlignCenter ); 174 l-> setAlignment ( Qt::AlignCenter );
167 l-> move ( 0, 0 ); 175 l-> move ( 0, 0 );
168 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 176 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
169 l-> show ( ); 177 l-> show ( );
170 QTimer::singleShot ( 3000, app, SLOT( quit ( ))); 178 QTimer::singleShot ( 3000, app, SLOT( quit ( )));
171 app-> exec ( ); 179 app-> exec ( );
172 delete app; 180 delete app;
173 qApp = 0; 181 qApp = 0;
174 } 182 }
175 } 183 }
176 else { 184 else {
177 if ( !autolog ) { 185 if ( !autolog ) {
178 Config cfg ( "opie-login" ); 186 QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf";
187 Config cfg ( confFile, Config::File );
179 cfg. setGroup ( "General" ); 188 cfg. setGroup ( "General" );
180 QString user = cfg. readEntry ( "AutoLogin" ); 189 QString user = cfg. readEntry ( "AutoLogin" );
181 190
182 if ( !user. isEmpty ( )) 191 if ( !user. isEmpty ( ))
183 autolog = ::strdup ( user. latin1 ( )); 192 autolog = ::strdup ( user. latin1 ( ));
184 } 193 }
185 194
186 if ( autolog ) { 195 if ( autolog && !userExited ) {
187 LoginApplication::setLoginAs ( autolog ); 196
197 QWSServer::setDesktopBackground( QImage() );
198 ODevice::inst ( )-> setDisplayStatus ( true );
199 ODevice::inst ( )-> setSoftSuspend ( false );
200 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
201 LoginApplication::setLoginAs ( autolog );
202
188 203
189 if ( LoginApplication::changeIdentity ( )) 204 if ( LoginApplication::changeIdentity ( ))
190 ::exit ( LoginApplication::login ( )); 205 ::exit ( LoginApplication::login ( ));
191 else 206 else
192 ::exit ( 0 ); 207 ::exit ( 0 );
193 } 208 }
194 else 209 else {
195 ::exit ( login_main ( argc, argv, ppid )); 210 ::exit ( login_main ( argc, argv, ppid ));
211 }
196 } 212 }
197 } 213 }
198 return 0; 214 return 0;
199} 215}
200 216
201void sigterm ( int /*sig*/ ) 217void sigterm ( int /*sig*/ )
202{ 218{
203 ::exit ( 0 ); 219 ::exit ( 0 );
204} 220}
205 221
206 222
207void exit_closelog ( ) 223void exit_closelog ( )
208{ 224{
209 ::closelog ( ); 225 ::closelog ( );
210} 226}
211 227
212 228
213class LoginScreenSaver : public QWSScreenSaver 229class LoginScreenSaver : public QWSScreenSaver
214{ 230{
215public: 231public:
216 LoginScreenSaver ( ) 232 LoginScreenSaver ( )
217 { 233 {
218 m_lcd_status = true; 234 m_lcd_status = true;
219 235
220 m_backlight_bright = -1; 236 m_backlight_bright = -1;
221 m_backlight_forcedoff = false; 237 m_backlight_forcedoff = false;
222 238
223 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 239 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
224 ODevice::inst ( )-> setDisplayStatus ( true ); 240 ODevice::inst ( )-> setDisplayStatus ( true );
225 } 241 }
226 void restore() 242 void restore()
227 { 243 {
228 if ( !m_lcd_status ) // We must have turned it off 244 if ( !m_lcd_status ) // We must have turned it off
229 ODevice::inst ( ) -> setDisplayStatus ( true ); 245 ODevice::inst ( ) -> setDisplayStatus ( true );
230 246
231 setBacklight ( -3 ); 247 setBacklight ( -3 );
232 } 248 }
233 bool save( int level ) 249 bool save( int level )
234 { 250 {
235 switch ( level ) { 251 switch ( level ) {
236 case 0: 252 case 0:
237 if ( backlight() > 1 ) 253 if ( backlight() > 1 )
238 setBacklight( 1 ); // lowest non-off 254 setBacklight( 1 ); // lowest non-off
239 return true; 255 return true;
240 break; 256 break;
241 case 1: 257 case 1:
242 setBacklight( 0 ); // off 258 setBacklight( 0 ); // off
243 return true; 259 return true;
244 break; 260 break;
245 case 2: 261 case 2:
246 // We're going to suspend the whole machine 262 // We're going to suspend the whole machine
247 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 263 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
248 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 264 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
249 return true; 265 return true;
250 } 266 }
251 break; 267 break;
252 } 268 }
253 return false; 269 return false;
254 } 270 }
255 271
256private: 272private:
257public: 273public:
258 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 274 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
259 { 275 {
260 int v [4]; 276 int v [4];
261 277
262 v [ 0 ] = QMAX( 1000 * i1, 100 ); 278 v [ 0 ] = QMAX( 1000 * i1, 100 );
263 v [ 1 ] = QMAX( 1000 * i2, 100 ); 279 v [ 1 ] = QMAX( 1000 * i2, 100 );
264 v [ 2 ] = QMAX( 1000 * i3, 100 ); 280 v [ 2 ] = QMAX( 1000 * i3, 100 );
265 v [ 3 ] = 0; 281 v [ 3 ] = 0;
266 282
267 if ( !i1 && !i2 && !i3 ) 283 if ( !i1 && !i2 && !i3 )
268 QWSServer::setScreenSaverInterval ( 0 ); 284 QWSServer::setScreenSaverInterval ( 0 );
269 else 285 else
270 QWSServer::setScreenSaverIntervals ( v ); 286 QWSServer::setScreenSaverIntervals ( v );
271 } 287 }
272 288
273 int backlight ( ) 289 int backlight ( )
274 { 290 {
275 if ( m_backlight_bright == -1 ) 291 if ( m_backlight_bright == -1 )
276 m_backlight_bright = 255; 292 m_backlight_bright = 255;
277 293
278 return m_backlight_bright; 294 return m_backlight_bright;
279 } 295 }
280 296
281 void setBacklight ( int bright ) 297 void setBacklight ( int bright )
282 { 298 {
283 if ( bright == -3 ) { 299 if ( bright == -3 ) {
284 // Forced on 300 // Forced on
285 m_backlight_forcedoff = false; 301 m_backlight_forcedoff = false;
286 bright = -1; 302 bright = -1;
287 } 303 }
288 if ( m_backlight_forcedoff && bright != -2 ) 304 if ( m_backlight_forcedoff && bright != -2 )
289 return ; 305 return ;
290 if ( bright == -2 ) { 306 if ( bright == -2 ) {
291 // Toggle between off and on 307 // Toggle between off and on
292 bright = m_backlight_bright ? 0 : -1; 308 bright = m_backlight_bright ? 0 : -1;
293 m_backlight_forcedoff = !bright; 309 m_backlight_forcedoff = !bright;
294 } 310 }
295 311
296 m_backlight_bright = bright; 312 m_backlight_bright = bright;
297 313
298 bright = backlight ( ); 314 bright = backlight ( );
299 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 315 ODevice::inst ( ) -> setDisplayBrightness ( bright );
300 316
301 m_backlight_bright = bright; 317 m_backlight_bright = bright;
302 } 318 }
303 319
304private: 320private:
305 bool m_lcd_status; 321 bool m_lcd_status;
306 322
307 int m_backlight_bright; 323 int m_backlight_bright;
308 bool m_backlight_forcedoff; 324 bool m_backlight_forcedoff;
309}; 325};
310 326
311 327
312namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting 328namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
313 329
314 330
315int login_main ( int argc, char **argv, pid_t ppid ) 331int login_main ( int argc, char **argv, pid_t ppid )
316{ 332{
317 QWSServer::setDesktopBackground( QImage() ); 333 QWSServer::setDesktopBackground( QImage() );
318 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 334 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
319 335
320 Opie::force_appearance = 0; 336 Opie::force_appearance = 0;
321 337
322 app-> setFont ( QFont ( "Helvetica", 10 )); 338 app-> setFont ( QFont ( "Helvetica", 10 ));
323 app-> setStyle ( new QPEStyle ( )); 339 app-> setStyle ( new QPEStyle ( ));
324 340
325 ODevice::inst ( )-> setSoftSuspend ( true ); 341 ODevice::inst ( )-> setSoftSuspend ( true );
326 342
327 if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 343 if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
328 if ( !QFile::exists ( "/etc/pointercal" )) { 344 if ( !QFile::exists ( "/etc/pointercal" )) {
329 // Make sure calibration widget starts on top. 345 // Make sure calibration widget starts on top.
330 Calibrate *cal = new Calibrate; 346 Calibrate *cal = new Calibrate;
331 cal-> exec ( ); 347 cal-> exec ( );
332 delete cal; 348 delete cal;
333 } 349 }
334 } 350 }
335 351
336 LoginScreenSaver *saver = new LoginScreenSaver; 352 LoginScreenSaver *saver = new LoginScreenSaver;
337 353
338 saver-> setIntervals ( ); 354 saver-> setIntervals ( );
339 QWSServer::setScreenSaver ( saver ); 355 QWSServer::setScreenSaver ( saver );
340 saver-> restore ( ); 356 saver-> restore ( );
341 357
342 358
343 LoginWindowImpl *lw = new LoginWindowImpl ( ); 359 LoginWindowImpl *lw = new LoginWindowImpl ( );
344 app-> setMainWidget ( lw ); 360 app-> setMainWidget ( lw );
345 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 361 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
346 lw-> show ( ); 362 lw-> show ( );
347 363
348 int rc = app-> exec ( ); 364 int rc = app-> exec ( );
349 365
350 ODevice::inst ( )-> setSoftSuspend ( false ); 366 ODevice::inst ( )-> setSoftSuspend ( false );
351 367
352 if ( app-> loginAs ( )) { 368 if ( app-> loginAs ( )) {
353 if ( app-> changeIdentity ( )) { 369 if ( app-> changeIdentity ( )) {
354 app-> login ( ); 370 app-> login ( );
355 371
356 // if login succeeds, it never comes back 372 // if login succeeds, it never comes back
357 373
358 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." )); 374 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." ));
359 rc = 1; 375 rc = 1;
360 } 376 }
361 else { 377 else {
362 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 378 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
363 rc = 2; 379 rc = 2;
364 } 380 }
365 381
366 } 382 }
367 return rc; 383 return rc;
368} 384}
369 385
diff --git a/core/opie-login/opie-login.conffiles b/core/opie-login/opie-login.conffiles
new file mode 100644
index 0000000..90645ee
--- a/dev/null
+++ b/core/opie-login/opie-login.conffiles
@@ -0,0 +1 @@
/opt/QtPalmtop/etc/opie-login.conf
diff --git a/core/opiealarm/Makefile b/core/opiealarm/Makefile
index 0c8467e..255083d 100644
--- a/core/opiealarm/Makefile
+++ b/core/opiealarm/Makefile
@@ -1,26 +1,22 @@
1 1
2DESTDIR=$(OPIEDIR)/bin 2DESTDIR=$(OPIEDIR)/bin
3 3
4CROSS:=arm-linux- 4CROSS:=arm-linux-
5CC :=$(CROSS)gcc 5CC :=$(CROSS)gcc
6LD :=$(CROSS)gcc 6LD :=$(CROSS)gcc
7STRIP:=$(CROSS)strip 7STRIP:=$(CROSS)strip
8 8
9CFLAGS:=-O2 9CFLAGS:=-O2
10LDFLAGS:= 10LDFLAGS:=
11 11
12all: $(DESTDIR)/opiealarm 12all: $(DESTDIR)/opiealarm
13 13
14$(DESTDIR)/opiealarm: opiealarm.c 14$(DESTDIR)/opiealarm: opiealarm.c
15 $(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS) 15 $(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS)
16 $(STRIP) --strip-all $(DESTDIR)/opiealarm 16 $(STRIP) --strip-all $(DESTDIR)/opiealarm
17 chmod u+s $(DESTDIR)/opiealarm 17 chmod u+s $(DESTDIR)/opiealarm
18 chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n" 18 chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n"
19 19
20clean: 20clean:
21 -rm -f *~ core 21 -rm -f *~ core
22 22
23install:
24 cp $(DESTDIR)/opiealarm $(INSTALL_ROOT)/opt/QtPalmtop/bin
25 chown root $(INSTALL_ROOT)/opt/QtPalmtop/bin/opiealarm
26 chmod u+s $(INSTALL_ROOT)/opt/QtPalmtop/bin/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n"
diff --git a/core/opiealarm/config.in b/core/opiealarm/config.in
index 2be9bd4..f86d01c 100644
--- a/core/opiealarm/config.in
+++ b/core/opiealarm/config.in
@@ -1,4 +1,4 @@
1config OPIEALARM 1config OPIEALARM
2 boolean "opie-opiealarm (Alarm daemon, sets RTC with wakeup time on suspend)" 2 boolean "Opiealarm (Alarm daemon, sets RTC with wakeup time on suspend)"
3 depends ! TARGET_X86 3 depends ! TARGET_X86
4 default "y" 4 default "y"
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 998cabd..90a743f 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -1,383 +1,384 @@
1/* 1/*
2 * opiealarm.c 2 * opiealarm.c
3 * 3 *
4 * This program is for extracting the event time/date out 4 * This program is for extracting the event time/date out
5 * of /var/run/resumeat and setting the RTC alarm to that time/date. 5 * of /var/run/resumeat and setting the RTC alarm to that time/date.
6 * It is designed to run via a script just before the iPAQ 6 * It is designed to run via a script just before the iPAQ
7 * is suspended and right after the iPAQ resumes operation. 7 * is suspended and right after the iPAQ resumes operation.
8 * 8 *
9 * written and copyrighted by Robert Griebl <sandman@handhelds.org> 9 * written and copyrighted by Robert Griebl <sandman@handhelds.org>
10 */ 10 */
11 11
12#include <stdio.h> 12#include <stdio.h>
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <sys/ioctl.h> 14#include <sys/ioctl.h>
15#include <sys/time.h> 15#include <sys/time.h>
16#include <sys/types.h> 16#include <sys/types.h>
17#include <fcntl.h> 17#include <fcntl.h>
18#include <unistd.h> 18#include <unistd.h>
19#include <errno.h> 19#include <errno.h>
20#include <time.h> 20#include <time.h>
21#include <stdlib.h> 21#include <stdlib.h>
22#include <syslog.h> 22#include <syslog.h>
23#include <signal.h> 23#include <signal.h>
24#include <errno.h> 24#include <errno.h>
25#include <string.h> 25#include <string.h>
26 26
27 27
28 #define PIDFILE "/var/run/opiealarm.pid" 28 #define PIDFILE "/var/run/opiealarm.pid"
29#define TIMEFILE "/var/run/resumeat" 29#define TIMEFILE "/var/run/resumeat"
30 #define APMFILE "/proc/apm" 30 #define APMFILE "/proc/apm"
31 31
32int resume ( int resuspend ); 32int resume ( int resuspend );
33int suspend ( int fix_rtc ); 33int suspend ( int fix_rtc );
34int main ( int argc, char **argv ); 34int main ( int argc, char **argv );
35int fork_with_pidfile ( void ); 35int fork_with_pidfile ( void );
36int kill_with_pidfile ( void ); 36int kill_with_pidfile ( void );
37void remove_pidfile ( void ); 37void remove_pidfile ( void );
38void usage ( void ); 38void usage ( void );
39void sig_handler_child ( int sig ); 39void sig_handler_child ( int sig );
40void sig_handler_parent ( int sig ); 40void sig_handler_parent ( int sig );
41int onac ( void ); 41int onac ( void );
42 42
43static int opiealarm_was_running; 43static int opiealarm_was_running;
44static pid_t parent_pid = 0; 44static pid_t parent_pid = 0;
45 45
46 46
47 47
48void sig_handler_child ( int sig ) 48void sig_handler_child ( int sig )
49{ 49{
50 // child got SIGUSR2 -> cleanup pidfile and exit 50 // child got SIGUSR2 -> cleanup pidfile and exit
51 51
52 remove_pidfile ( ); 52 remove_pidfile ( );
53 exit ( 0 ); 53 exit ( 0 );
54} 54}
55 55
56void sig_handler_parent ( int sig ) 56void sig_handler_parent ( int sig )
57{ 57{
58 // parent got SIGUSR1 -> safe to exit now 58 // parent got SIGUSR1 -> safe to exit now
59 59
60 parent_pid = 0; 60 parent_pid = 0;
61 exit ( 0 ); 61 exit ( 0 );
62} 62}
63 63
64void usage ( void ) 64void usage ( void )
65{ 65{
66 fprintf ( stderr, "Usage: opiealarm -s [-f] | -r [-a]\n\n" ); 66 fprintf ( stderr, "Usage: opiealarm -s [-f] | -r [-a]\n\n" );
67 fprintf ( stderr, "\t-s\tSuspend mode: set RTC alarm\n" ); 67 fprintf ( stderr, "\t-s\tSuspend mode: set RTC alarm\n" );
68 fprintf ( stderr, "\t-f \tFix RTC, if RTC and system have more than 5sec difference (suspend mode)\n" ); 68 fprintf ( stderr, "\t-f \tFix RTC, if RTC and system have more than 5sec difference (suspend mode)\n" );
69 fprintf ( stderr, "\t-r\tResume mode: kill running opiealarm\n" ); 69 fprintf ( stderr, "\t-r\tResume mode: kill running opiealarm\n" );
70 fprintf ( stderr, "\t-a <x>\tResuspend in <x> seconds (resume mode)\n\n" ); 70 fprintf ( stderr, "\t-a <x>\tResuspend in <x> seconds (resume mode)\n\n" );
71 exit ( 1 ); 71 exit ( 1 );
72} 72}
73 73
74int fork_with_pidfile ( void ) 74int fork_with_pidfile ( void )
75{ 75{
76 FILE *fp; 76 FILE *fp;
77 pid_t pid; 77 pid_t pid;
78 78
79 pid = fork ( ); 79 pid = fork ( );
80 80
81 if ( pid > 0 ) { 81 if ( pid > 0 ) {
82 // We can not just exit now, because the kernel could suspend 82 // We can not just exit now, because the kernel could suspend
83 // the iPAQ just before the child process sets the RTC. 83 // the iPAQ just before the child process sets the RTC.
84 // Solution: just wait for SIGUSR1 - the child process will 84 // Solution: just wait for SIGUSR1 - the child process will
85 // signal this when it thinks it is safe to exit. 85 // signal this when it thinks it is safe to exit.
86 86
87 signal ( SIGUSR1, sig_handler_parent ); 87 signal ( SIGUSR1, sig_handler_parent );
88 while ( 1 ) 88 while ( 1 )
89 sleep ( 1000 ); 89 sleep ( 1000 );
90 exit ( 0 ); 90 exit ( 0 );
91 } 91 }
92 else if ( pid < 0 ) { 92 else if ( pid < 0 ) {
93 perror ( "forking failed" ); 93 perror ( "forking failed" );
94 return 0; 94 return 0;
95 } 95 }
96 //sleep( 60 );
96 97
97 // child process needs to react to SIGUSR2. This is sent when 98 // child process needs to react to SIGUSR2. This is sent when
98 // a new opiealarm process is started. 99 // a new opiealarm process is started.
99 100
100 signal ( SIGUSR2, sig_handler_child ); 101 signal ( SIGUSR2, sig_handler_child );
101 102
102 // save pid 103 // save pid
103 if (( fp = fopen ( PIDFILE, "w" ))) { 104 if (( fp = fopen ( PIDFILE, "w" ))) {
104 fprintf ( fp, "%d", getpid ( )); 105 fprintf ( fp, "%d", getpid ( ));
105 fclose ( fp ); 106 fclose ( fp );
106 107
107 // detach 108 // detach
108 close ( 0 ); 109 close ( 0 );
109 close ( 1 ); 110 close ( 1 );
110 close ( 2 ); 111 close ( 2 );
111 112
112 setpgid ( 0, 0 ); 113 setpgid ( 0, 0 );
113 114
114 return 1; 115 return 1;
115 } 116 }
116 else { 117 else {
117 perror ( PIDFILE ); 118 perror ( PIDFILE );
118 return 0; 119 return 0;
119 } 120 }
120} 121}
121 122
122int kill_with_pidfile ( void ) 123int kill_with_pidfile ( void )
123{ 124{
124 FILE *fp; 125 FILE *fp;
125 pid_t pid; 126 pid_t pid;
126 int res = 0; 127 int res = 0;
127 128
128 // terminate a running opiealarm child process 129 // terminate a running opiealarm child process
129 // return 1 if we really killed one 130 // return 1 if we really killed one
130 131
131 if (( fp = fopen ( PIDFILE, "r" ))) { 132 if (( fp = fopen ( PIDFILE, "r" ))) {
132 if ( fscanf ( fp, "%d", &pid ) == 1 ) 133 if ( fscanf ( fp, "%d", &pid ) == 1 )
133 res = ( kill ( pid, SIGUSR2 ) == 0 ) ? 1 : 0; 134 res = ( kill ( pid, SIGUSR2 ) == 0 ) ? 1 : 0;
134 fclose ( fp ); 135 fclose ( fp );
135 } 136 }
136 return res; 137 return res;
137} 138}
138 139
139void remove_pidfile ( void ) 140void remove_pidfile ( void )
140{ 141{
141 // child is about to exit - cleanup 142 // child is about to exit - cleanup
142 143
143 unlink ( PIDFILE ); 144 unlink ( PIDFILE );
144 signal ( SIGUSR2, SIG_DFL ); 145 signal ( SIGUSR2, SIG_DFL );
145} 146}
146 147
147 148
148int main ( int argc, char **argv ) 149int main ( int argc, char **argv )
149{ 150{
150 int mode = 0; 151 int mode = 0;
151 int ac_resusp = 0; 152 int ac_resusp = 0;
152 int fix_rtc = 0; 153 int fix_rtc = 0;
153 int opt; 154 int opt;
154 155
155 while (( opt = getopt ( argc, argv, "a:frs" )) != EOF ) { 156 while (( opt = getopt ( argc, argv, "a:frs" )) != EOF ) {
156 switch ( opt ) { 157 switch ( opt ) {
157 case 's': 158 case 's':
158 mode = 's'; 159 mode = 's';
159 break; 160 break;
160 case 'r': 161 case 'r':
161 mode = 'r'; 162 mode = 'r';
162 break; 163 break;
163 case 'a': 164 case 'a':
164 ac_resusp = atoi ( optarg ); 165 ac_resusp = atoi ( optarg );
165 if ( ac_resusp < 30 ) { 166 if ( ac_resusp < 30 ) {
166 ac_resusp = 120; 167 ac_resusp = 120;
167 168
168 fprintf ( stderr, "Warning: resuspend timeout must be >= 30 sec. -- now set to 120 sec\n" ); 169 fprintf ( stderr, "Warning: resuspend timeout must be >= 30 sec. -- now set to 120 sec\n" );
169 } 170 }
170 break; 171 break;
171 case 'f': 172 case 'f':
172 fix_rtc = 1; 173 fix_rtc = 1;
173 break; 174 break;
174 default: 175 default:
175 usage ( ); 176 usage ( );
176 } 177 }
177 } 178 }
178 179
179 if ( geteuid ( ) != 0 ) { 180 if ( geteuid ( ) != 0 ) {
180 fprintf ( stderr, "You need root priviledges to run opiealarm." ); 181 fprintf ( stderr, "You need root priviledges to run opiealarm." );
181 return 2; 182 return 2;
182 } 183 }
183 184
184 if ( !mode ) 185 if ( !mode )
185 usage ( ); 186 usage ( );
186 187
187 188
188 parent_pid = getpid ( ); 189 parent_pid = getpid ( );
189 190
190 // kill running opiealarm 191 // kill running opiealarm
191 opiealarm_was_running = kill_with_pidfile ( ); 192 opiealarm_was_running = kill_with_pidfile ( );
192 remove_pidfile ( ); 193 remove_pidfile ( );
193 194
194 switch ( mode ) { 195 switch ( mode ) {
195 case 'r': opt = resume ( ac_resusp ); 196 case 'r': opt = resume ( ac_resusp );
196 break; 197 break;
197 case 's': 198 case 's':
198 default : opt = suspend ( fix_rtc ); 199 default : opt = suspend ( fix_rtc );
199 break; 200 break;
200 } 201 }
201 202
202 parent_pid = 0; 203 parent_pid = 0;
203 return opt; 204 return opt;
204 } 205 }
205 206
206 207
207int suspend ( int fix_rtc ) 208int suspend ( int fix_rtc )
208{ 209{
209 FILE *fp; 210 FILE *fp = NULL;
210 char buf [64]; 211 char buf [64];
211 time_t alrt, syst, rtct; 212 time_t alrt, syst, rtct;
212 struct tm alr, sys, rtc; 213 struct tm alr, sys, rtc;
213 int fd; 214 int fd;
214 int rtc_sys_diff; 215 int rtc_sys_diff;
215 216
216 217
217 if ( !fork_with_pidfile ( )) 218 if ( !fork_with_pidfile ( ))
218 return 3; 219 return 3;
219 220
220 // we are the child process from here on ... 221 // we are the child process from here on ...
221 222
222 tzset ( ); // not sure if it is really needed -- it probably doesn't hurt ... 223 tzset ( ); // not sure if it is really needed -- it probably doesn't hurt ...
223 224
224 time ( &syst );// get the UNIX system time 225 time ( &syst );// get the UNIX system time
225 sys = *localtime ( &syst ); 226 sys = *localtime ( &syst );
226 227
227 do { 228 do {
228 229
229 if (( fd = open ( "/dev/misc/rtc", O_RDWR )) < 0 ) 230 if (( fd = open ( "/dev/misc/rtc", O_RDWR )) < 0 )
230 if (( fd = open ( "/dev/rtc", O_RDWR )) < 0 ) 231 if (( fd = open ( "/dev/rtc", O_RDWR )) < 0 )
231 break; // ( 1, "rtc" ); 232 break; // ( 1, "rtc" );
232 233
233 memset ( &rtc, 0, sizeof ( struct tm )); // get the RTC time 234 memset ( &rtc, 0, sizeof ( struct tm )); // get the RTC time
234 235
235 if ( ioctl ( fd, RTC_RD_TIME, &rtc ) < 0 ) 236 if ( ioctl ( fd, RTC_RD_TIME, &rtc ) < 0 )
236 break; // ( 1, "ioctl RTC_RD_TIME" ); 237 break; // ( 1, "ioctl RTC_RD_TIME" );
237 238
238 rtct = mktime ( &rtc ); 239 rtct = mktime ( &rtc );
239 240
240 rtc_sys_diff = ( syst - rtct ) - sys. tm_gmtoff; // calculate the difference between system and hardware time 241 rtc_sys_diff = ( syst - rtct ) - sys. tm_gmtoff; // calculate the difference between system and hardware time
241 242
242 if ( fix_rtc && (( rtc_sys_diff < -3 ) || ( rtc_sys_diff > 3 ))) { 243 if ( fix_rtc && (( rtc_sys_diff < -3 ) || ( rtc_sys_diff > 3 ))) {
243 struct tm set; 244 struct tm set;
244 set = *gmtime ( &syst ); 245 set = *gmtime ( &syst );
245 246
246 // if the difference between system and hardware time is more than 3 seconds, 247 // if the difference between system and hardware time is more than 3 seconds,
247 // we have to set the RTC (hwclock --systohc), or alarms won't work reliably. 248 // we have to set the RTC (hwclock --systohc), or alarms won't work reliably.
248 249
249 if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 ) 250 if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 )
250 break; // ( 1, "ioctl RTC_SET_TIME" ); 251 break; // ( 1, "ioctl RTC_SET_TIME" );
251 } 252 }
252 253
253 // read the wakeup time from TIMEFILE 254 // read the wakeup time from TIMEFILE
254 if (!( fp = fopen ( TIMEFILE, "r" ))) 255 if (!( fp = fopen ( TIMEFILE, "r" )))
255 break; // ( 1, TIMEFILE ); 256 break; // ( 1, TIMEFILE );
256 257
257 if ( !fgets ( buf, sizeof( buf ) - 1, fp )) 258 if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
258 break; // ( 1, TIMEFILE ); 259 break; // ( 1, TIMEFILE );
259 260
260 fclose ( fp ); 261 fclose ( fp );
261 fp = 0; 262 fp = NULL;
262 263
263 alrt = atoi ( buf ); // get the alarm time 264 alrt = atoi ( buf ); // get the alarm time
264 265
265 if ( alrt == 0 ) 266 if ( alrt == 0 )
266 break; // ( 0, TIMEFILE " contains an invalid time description" ); 267 break; // ( 0, TIMEFILE " contains an invalid time description" );
267 alrt -= 5; // wake up 5 sec before the specified time 268 alrt -= 5; // wake up 5 sec before the specified time
268 269
269 alr = *gmtime ( &alrt ); 270 alr = *gmtime ( &alrt );
270 271
271 if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 ) // set RTC alarm time 272 if ( ioctl ( fd, RTC_ALM_SET, &alr ) < 0 ) // set RTC alarm time
272 break; // ( 1, "ioctl RTC_ALM_SET" ); 273 break; // ( 1, "ioctl RTC_ALM_SET" );
273 274
274 if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 ) 275 if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 )
275 break; // ( 1, "ioctl RTC_AIE_ON" ); // enable RTC alarm irq 276 break; // ( 1, "ioctl RTC_AIE_ON" ); // enable RTC alarm irq
276 277
277 // tell the parent it is safe to exit now .. we have set the RTC alarm 278 // tell the parent it is safe to exit now .. we have set the RTC alarm
278 kill ( parent_pid, SIGUSR1 ); 279 kill ( parent_pid, SIGUSR1 );
279 280
280 if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq 281 if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq
281 break; // ( 1, "read rtc alarm" ); 282 break; // ( 1, "read rtc alarm" );
282 283
283 // iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2 284 // iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2
284 // from the "resume instance" of opiealarm. 285 // from the "resume instance" of opiealarm.
285 286
286 if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq 287 if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq
287 break; // ( 1, "ioctl RTC_AIE_OFF" ); 288 break; // ( 1, "ioctl RTC_AIE_OFF" );
288 289
289 close ( fd ); 290 close ( fd );
290 fd = -1; 291 fd = -1;
291 292
292 remove_pidfile ( ); 293 remove_pidfile ( );
293 294
294 return 0; 295 return 0;
295 296
296 } while ( 0 ); 297 } while ( 0 );
297 298
298 if ( fp != NULL ) 299 if ( fp != NULL )
299 fclose ( fp ); 300 fclose ( fp );
300 301
301 if ( fd != -1 ) 302 if ( fd != -1 )
302 close ( fd ); 303 close ( fd );
303 304
304 kill ( parent_pid, SIGUSR1 ); 305 kill ( parent_pid, SIGUSR1 );
305 306
306 while ( 1 ) // pretend that we are waiting on RTC, so opiealarm -r can kill us 307 while ( 1 ) // pretend that we are waiting on RTC, so opiealarm -r can kill us
307 sleep ( 1000 ); // if we don't do this, the "resuspend on AC" would be triggerd 308 sleep ( 1000 ); // if we don't do this, the "resuspend on AC" would be triggerd
308 return 0; 309 return 0;
309} 310}
310 311
311int onac ( void ) 312int onac ( void )
312{ 313{
313 FILE *fp; 314 FILE *fp;
314 int on = 0; 315 int on = 0;
315 316
316 // check the apm proc interface for AC status 317 // check the apm proc interface for AC status
317 318
318 if (( fp = fopen ( APMFILE, "r" ))) { 319 if (( fp = fopen ( APMFILE, "r" ))) {
319 int ac = 0; 320 int ac = 0;
320 321
321 if ( fscanf ( fp, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%*x 0x%*x %*d%% %*i %*c", &ac ) == 1 ) 322 if ( fscanf ( fp, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%*x 0x%*x %*d%% %*i %*c", &ac ) == 1 )
322 on = ( ac == 0x01 ) ? 1 : 0; 323 on = ( ac == 0x01 ) ? 1 : 0;
323 324
324 fclose ( fp ); 325 fclose ( fp );
325 } 326 }
326 return on; 327 return on;
327} 328}
328 329
329int resume ( int resuspend ) 330int resume ( int resuspend )
330{ 331{
331 FILE *fp; 332 FILE *fp;
332 333
333 // re-suspend when on AC (optional) when woken up via RTC 334 // re-suspend when on AC (optional) when woken up via RTC
334 335
335 if ( !opiealarm_was_running ) { 336 if ( !opiealarm_was_running ) {
336 // if opiealarm -s didn't wake up via RTC, the old process gets killed 337 // if opiealarm -s didn't wake up via RTC, the old process gets killed
337 // by kill_by_pidfile(), which is recorded in opiealarm_was_running 338 // by kill_by_pidfile(), which is recorded in opiealarm_was_running
338 339
339 if ( resuspend && onac ( )) { 340 if ( resuspend && onac ( )) {
340 time_t start, now; 341 time_t start, now;
341 char *argv [4]; 342 char *argv [4];
342 343
343 if ( !fork_with_pidfile ( )) 344 if ( !fork_with_pidfile ( ))
344 return 4; 345 return 4;
345 346
346 // we can't wait for the resuspend timeout in the parent process. 347 // we can't wait for the resuspend timeout in the parent process.
347 // so we fork and tell the parent it can exit immediatly 348 // so we fork and tell the parent it can exit immediatly
348 349
349 kill ( parent_pid, SIGUSR1 ); 350 kill ( parent_pid, SIGUSR1 );
350 351
351 // sleep <resuspend> seconds - this method is much more precise than sleep() ! 352 // sleep <resuspend> seconds - this method is much more precise than sleep() !
352 time ( &start ); 353 time ( &start );
353 do { 354 do {
354 sleep ( 1 ); 355 sleep ( 1 );
355 time ( &now ); 356 time ( &now );
356 } while (( now - start ) < resuspend ); 357 } while (( now - start ) < resuspend );
357 358
358 if ( onac ( )) { // still on ac ? 359 if ( onac ( )) { // still on ac ?
359 argv[0] = "qcop"; 360 argv[0] = "qcop";
360 argv[1] = "QPE/Desktop"; 361 argv[1] = "QPE/Desktop";
361 argv[2] = "suspend()"; 362 argv[2] = "suspend()";
362 argv[3] = 0; 363 argv[3] = 0;
363 364
364 // hard coded for now ...but needed 365 // hard coded for now ...but needed
365 // another way would be to simulate a power-button press 366 // another way would be to simulate a power-button press
366 367
367 setenv ( "LOGNAME", "root", 1 ); 368 setenv ( "LOGNAME", "root", 1 );
368 setenv ( "HOME", "/root", 1 ); 369 setenv ( "HOME", "/root", 1 );
369 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 ); 370 setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 );
370 setenv ( "QTDIR", "/opt/QtPalmtop", 1 ); 371 setenv ( "QTDIR", "/opt/QtPalmtop", 1 );
371 372
372 remove_pidfile ( ); 373 remove_pidfile ( );
373 374
374 // no need for system() since this process is no longer usefull anyway 375 // no need for system() since this process is no longer usefull anyway
375 execv ( "/opt/QtPalmtop/bin/qcop", argv ); 376 execv ( "/opt/QtPalmtop/bin/qcop", argv );
376 377
377 perror ( "exec for qcop failed" ); 378 perror ( "exec for qcop failed" );
378 return 5; 379 return 5;
379 } 380 }
380 } 381 }
381 } 382 }
382 return 0; 383 return 0;
383} 384}
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp
index 5f68010..de99a09 100644
--- a/core/settings/launcher/tabdialog.cpp
+++ b/core/settings/launcher/tabdialog.cpp
@@ -1,352 +1,352 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31 31
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qtabbar.h> 34#include <qtabbar.h>
35#include <qiconview.h> 35#include <qiconview.h>
36#include <qapplication.h> 36#include <qapplication.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qradiobutton.h> 38#include <qradiobutton.h>
39#include <qbuttongroup.h> 39#include <qbuttongroup.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qwhatsthis.h> 41#include <qwhatsthis.h>
42#include <qcheckbox.h> 42#include <qcheckbox.h>
43 43
44#include <opie/ofontselector.h> 44#include <opie/ofontselector.h>
45#include <opie/otabwidget.h> 45#include <opie/otabwidget.h>
46#include <opie/ocolorbutton.h> 46#include <opie/ocolorbutton.h>
47#include <opie/ofiledialog.h> 47#include <opie/ofiledialog.h>
48 48
49#include "tabdialog.h" 49#include "tabdialog.h"
50 50
51 51
52class SampleItem : public QIconViewItem { 52class SampleItem : public QIconViewItem {
53public: 53public:
54 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text ) 54 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text )
55 { 55 {
56 m_large = pix; 56 m_large = pix;
57 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 )); 57 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 ));
58 } 58 }
59 59
60 void sizeChange ( ) 60 void sizeChange ( )
61 { 61 {
62 calcRect ( ); 62 calcRect ( );
63 repaint ( ); 63 repaint ( );
64 } 64 }
65 65
66 QPixmap *pixmap ( ) const 66 QPixmap *pixmap ( ) const
67 { 67 {
68 if ( iconView ( )-> itemTextPos ( ) == QIconView::Right ) 68 if ( iconView ( )-> itemTextPos ( ) == QIconView::Right )
69 return (QPixmap *) &m_small; 69 return (QPixmap *) &m_small;
70 else 70 else
71 return (QPixmap *) &m_large; 71 return (QPixmap *) &m_large;
72 } 72 }
73 73
74private: 74private:
75 QPixmap m_large, m_small; 75 QPixmap m_large, m_small;
76}; 76};
77 77
78class SampleView : public QIconView { 78class SampleView : public QIconView {
79public: 79public:
80 SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name ) 80 SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name )
81 { 81 {
82 setItemsMovable ( false ); 82 setItemsMovable ( false );
83 setAutoArrange ( true ); 83 setAutoArrange ( true );
84 setSorting ( true ); 84 setSorting ( true );
85 setFrameStyle ( QFrame::NoFrame ); 85 setFrameStyle ( QFrame::NoFrame );
86 setSpacing ( 4 ); 86 setSpacing ( 4 );
87 setMargin ( 0 ); 87 setMargin ( 0 );
88 setSelectionMode ( QIconView::NoSelection ); 88 setSelectionMode ( QIconView::NoSelection );
89 setBackgroundMode ( PaletteBase ); 89 setBackgroundMode ( PaletteBase );
90 setViewMode ( TabConfig::Icon ); 90 setViewMode ( TabConfig::Icon );
91 calculateGrid ( Bottom ); 91 calculateGrid ( Bottom );
92 92
93 93
94 new SampleItem ( this, tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); 94 new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" ));
95 new SampleItem ( this, tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); 95 new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" ));
96 new SampleItem ( this, tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); 96 new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" ));
97 97
98 setBackgroundType ( TabConfig::Ruled, QString::null ); 98 setBackgroundType ( TabConfig::Ruled, QString::null );
99 99
100 setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); 100 setMaximumHeight ( firstItem ( )-> height ( ) + 16 );
101 } 101 }
102 102
103 void setViewMode ( TabConfig::ViewMode m ) 103 void setViewMode ( TabConfig::ViewMode m )
104 { 104 {
105 viewport ( )-> setUpdatesEnabled ( false ); 105 viewport ( )-> setUpdatesEnabled ( false );
106 106
107 switch ( m ) { 107 switch ( m ) {
108 case TabConfig::List: 108 case TabConfig::List:
109 setItemTextPos( QIconView::Right ); 109 setItemTextPos( QIconView::Right );
110 break; 110 break;
111 case TabConfig::Icon: 111 case TabConfig::Icon:
112 setItemTextPos( QIconView::Bottom ); 112 setItemTextPos( QIconView::Bottom );
113 break; 113 break;
114 } 114 }
115 // hideOrShowItems ( false ); 115 // hideOrShowItems ( false );
116 116
117 for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) 117 for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( ))
118 ((SampleItem *) it )-> sizeChange ( ); 118 ((SampleItem *) it )-> sizeChange ( );
119 arrangeItemsInGrid ( true ); 119 arrangeItemsInGrid ( true );
120 viewport ( )-> setUpdatesEnabled ( true ); 120 viewport ( )-> setUpdatesEnabled ( true );
121 update ( ); 121 update ( );
122 } 122 }
123 123
124 124
125 void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) 125 void setBackgroundType( TabConfig::BackgroundType t, const QString &val )
126 { 126 {
127 switch ( t ) { 127 switch ( t ) {
128 case TabConfig::Ruled: { 128 case TabConfig::Ruled: {
129 QPixmap bg ( width ( ), 9 ); 129 QPixmap bg ( width ( ), 9 );
130 QPainter painter ( &bg ); 130 QPainter painter ( &bg );
131 for ( int i = 0; i < 3; i++ ) { 131 for ( int i = 0; i < 3; i++ ) {
132 painter. setPen ( white ); 132 painter. setPen ( white );
133 painter. drawLine ( 0, i*3, width()-1, i*3 ); 133 painter. drawLine ( 0, i*3, width()-1, i*3 );
134 painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); 134 painter. drawLine ( 0, i*3+1, width()-1, i*3+1 );
135 painter. setPen ( colorGroup().background().light(105) ); 135 painter. setPen ( colorGroup().background().light(105) );
136 painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); 136 painter. drawLine ( 0, i*3+2, width()-1, i*3+2 );
137 } 137 }
138 painter.end ( ); 138 painter.end ( );
139 setBackgroundPixmap ( bg ); 139 setBackgroundPixmap ( bg );
140 break; 140 break;
141 } 141 }
142 142
143 case TabConfig::SolidColor: { 143 case TabConfig::SolidColor: {
144 setBackgroundPixmap ( QPixmap ( )); 144 setBackgroundPixmap ( QPixmap ( ));
145 if ( val. isEmpty ( )) 145 if ( val. isEmpty ( ))
146 setBackgroundColor ( colorGroup ( ). base ( )); 146 setBackgroundColor ( colorGroup ( ). base ( ));
147 else 147 else
148 setBackgroundColor ( val ); 148 setBackgroundColor ( val );
149 break; 149 break;
150 } 150 }
151 151
152 case TabConfig::Image: { 152 case TabConfig::Image: {
153 qDebug( "Loading image: %s", val.latin1() ); 153 qDebug( "Loading image: %s", val.latin1() );
154 QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); 154 QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val ));
155 if ( bg. isNull ( )) { 155 if ( bg. isNull ( )) {
156 QImageIO imgio; 156 QImageIO imgio;
157 imgio. setFileName ( val ); 157 imgio. setFileName ( val );
158 QSize ds = qApp-> desktop ( )-> size ( ); 158 QSize ds = qApp-> desktop ( )-> size ( );
159 QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr 159 QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr
160 imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); 160 imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( ));
161 imgio. read ( ); 161 imgio. read ( );
162 bg = imgio. image ( ); 162 bg = imgio. image ( );
163 } 163 }
164 setBackgroundPixmap ( bg ); 164 setBackgroundPixmap ( bg );
165 break; 165 break;
166 } 166 }
167 } 167 }
168 m_bgtype = t; 168 m_bgtype = t;
169 viewport ( )-> update ( ); 169 viewport ( )-> update ( );
170 } 170 }
171 171
172 void setTextColor ( const QColor &tc ) 172 void setTextColor ( const QColor &tc )
173 { 173 {
174 m_textcolor = tc; 174 m_textcolor = tc;
175 QColorGroup cg = colorGroup ( ); 175 QColorGroup cg = colorGroup ( );
176 cg. setColor ( QColorGroup::Text, tc ); 176 cg. setColor ( QColorGroup::Text, tc );
177 setPalette ( QPalette ( cg, cg, cg )); 177 setPalette ( QPalette ( cg, cg, cg ));
178 viewport ( )-> update ( ); 178 viewport ( )-> update ( );
179 } 179 }
180 180
181 void setViewFont ( const QFont &f ) 181 void setViewFont ( const QFont &f )
182 { 182 {
183 setFont ( f ); 183 setFont ( f );
184 } 184 }
185 185
186 void setItemTextPos ( ItemTextPos pos ) 186 void setItemTextPos ( ItemTextPos pos )
187 { 187 {
188 calculateGrid ( pos ); 188 calculateGrid ( pos );
189 QIconView::setItemTextPos( pos ); 189 QIconView::setItemTextPos( pos );
190 } 190 }
191 191
192 void calculateGrid ( ItemTextPos pos ) 192 void calculateGrid ( ItemTextPos pos )
193 { 193 {
194 int dw = QApplication::desktop ( )-> width ( ); 194 int dw = QApplication::desktop ( )-> width ( );
195 int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); 195 int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( );
196 if ( pos == Bottom ) { 196 if ( pos == Bottom ) {
197 int cols = 3; 197 int cols = 3;
198 if ( viewerWidth <= 200 ) 198 if ( viewerWidth <= 200 )
199 cols = 2; 199 cols = 2;
200 else if ( viewerWidth >= 400 ) 200 else if ( viewerWidth >= 400 )
201 cols = viewerWidth/96; 201 cols = viewerWidth/96;
202 setSpacing ( 4 ); 202 setSpacing ( 4 );
203 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); 203 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols );
204 setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); 204 setGridY ( fontMetrics ( ). height ( ) * 2 + 24 );
205 } 205 }
206 else { 206 else {
207 int cols = 2; 207 int cols = 2;
208 if ( viewerWidth < 150 ) 208 if ( viewerWidth < 150 )
209 cols = 1; 209 cols = 1;
210 else if ( viewerWidth >= 400 ) 210 else if ( viewerWidth >= 400 )
211 cols = viewerWidth / 150; 211 cols = viewerWidth / 150;
212 setSpacing ( 2 ); 212 setSpacing ( 2 );
213 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); 213 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols );
214 setGridY ( fontMetrics ( ). height ( ) + 2 ); 214 setGridY ( fontMetrics ( ). height ( ) + 2 );
215 } 215 }
216 } 216 }
217 217
218 void paletteChange( const QPalette &p ) 218 void paletteChange( const QPalette &p )
219 { 219 {
220 static bool excllock = false; 220 static bool excllock = false;
221 221
222 if ( excllock ) 222 if ( excllock )
223 return; 223 return;
224 excllock = true; 224 excllock = true;
225 225
226 unsetPalette ( ); 226 unsetPalette ( );
227 QIconView::paletteChange ( p ); 227 QIconView::paletteChange ( p );
228 if ( m_bgtype == TabConfig::Ruled ) 228 if ( m_bgtype == TabConfig::Ruled )
229 setBackgroundType ( TabConfig::Ruled, QString::null ); 229 setBackgroundType ( TabConfig::Ruled, QString::null );
230 QColorGroup cg = colorGroup ( ); 230 QColorGroup cg = colorGroup ( );
231 cg.setColor ( QColorGroup::Text, m_textcolor ); 231 cg.setColor ( QColorGroup::Text, m_textcolor );
232 setPalette ( QPalette ( cg, cg, cg )); 232 setPalette ( QPalette ( cg, cg, cg ));
233 233
234 excllock = false; 234 excllock = false;
235 } 235 }
236 236
237 void setBackgroundPixmap ( const QPixmap &pm ) 237 void setBackgroundPixmap ( const QPixmap &pm )
238 { 238 {
239 m_bgpix = pm; 239 m_bgpix = pm;
240 } 240 }
241 241
242 void setBackgroundColor ( const QColor &c ) 242 void setBackgroundColor ( const QColor &c )
243 { 243 {
244 m_bgcolor = c; 244 m_bgcolor = c;
245 } 245 }
246 246
247 void drawBackground ( QPainter *p, const QRect &r ) 247 void drawBackground ( QPainter *p, const QRect &r )
248 { 248 {
249 if ( !m_bgpix. isNull ( )) { 249 if ( !m_bgpix. isNull ( )) {
250 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), 250 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ),
251 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); 251 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( )));
252 } 252 }
253 else 253 else
254 p-> fillRect ( r, m_bgcolor ); 254 p-> fillRect ( r, m_bgcolor );
255 } 255 }
256 256
257private: 257private:
258 QColor m_textcolor; 258 QColor m_textcolor;
259 QColor m_bgcolor; 259 QColor m_bgcolor;
260 QPixmap m_bgpix; 260 QPixmap m_bgpix;
261 TabConfig::BackgroundType m_bgtype; 261 TabConfig::BackgroundType m_bgtype;
262}; 262};
263 263
264 264
265 265
266TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) 266TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl )
267 : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) 267 : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc )
268{ 268{
269 setCaption ( tr( "Edit Tab" )); 269 setCaption ( tr( "Edit Tab" ));
270 270
271 QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); 271 QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 );
272 272
273 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 273 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
274 QWidget *bgtab; 274 QWidget *bgtab;
275 275
276 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); 276 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" ));
277 tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); 277 tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" ));
278 tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); 278 tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) );
279 279
280 tw-> setCurrentTab ( bgtab ); 280 tw-> setCurrentTab ( bgtab );
281 281
282 QWidget *sample = new QVBox ( this ); 282 QWidget *sample = new QVBox ( this );
283 QTabBar *tb = new QTabBar ( sample ); 283 QTabBar *tb = new QTabBar ( sample );
284 QString name ( tr( "Previewing %1" ). arg ( tabname )); 284 QString name ( tr( "Previewing %1" ). arg ( tabname ));
285 285
286 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); 286 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name ));
287 287
288 m_sample = new SampleView ( sample ); 288 m_sample = new SampleView ( sample );
289 289
290 lay-> addWidget ( tw, 10 ); 290 lay-> addWidget ( tw, 10 );
291 lay-> addWidget ( sample, 1 ); 291 lay-> addWidget ( sample, 1 );
292 292
293 m_iconsize-> setButton ( tc. m_view ); 293 m_iconsize-> setButton ( tc. m_view );
294 iconSizeClicked ( tc. m_view ); 294 iconSizeClicked ( tc. m_view );
295 //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); 295 //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color ));
296 iconColorClicked ( m_iconcolor-> color ( )); 296 iconColorClicked ( m_iconcolor-> color ( ));
297 m_bgtype-> setButton ( tc. m_bg_type ); 297 m_bgtype-> setButton ( tc. m_bg_type );
298 //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); 298 //m_solidcolor-> setColor ( QColor ( tc. m_bg_color ));
299 m_bgimage = tc. m_bg_image; 299 m_bgimage = tc. m_bg_image;
300 bgTypeClicked ( tc. m_bg_type ); 300 bgTypeClicked ( tc. m_bg_type );
301 m_fontuse-> setChecked ( tc. m_font_use ); 301 m_fontuse-> setChecked ( tc. m_font_use );
302 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); 302 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic ));
303 m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); 303 m_fontselect-> setEnabled ( m_fontuse-> isChecked ( ));
304 fontClicked ( m_fontselect-> selectedFont ( )); 304 fontClicked ( m_fontselect-> selectedFont ( ));
305 305
306 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); 306 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." ));
307} 307}
308 308
309 309
310TabDialog::~TabDialog ( ) 310TabDialog::~TabDialog ( )
311{ 311{
312} 312}
313 313
314QWidget *TabDialog::createFontTab ( QWidget *parent ) 314QWidget *TabDialog::createFontTab ( QWidget *parent )
315{ 315{
316 QWidget *tab = new QWidget ( parent, "FontTab" ); 316 QWidget *tab = new QWidget ( parent, "FontTab" );
317 QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); 317 QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 );
318 318
319 m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); 319 m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab );
320 vertLayout-> addWidget ( m_fontuse ); 320 vertLayout-> addWidget ( m_fontuse );
321 321
322 m_fontselect = new OFontSelector ( false, tab, "fontsel" ); 322 m_fontselect = new OFontSelector ( false, tab, "fontsel" );
323 vertLayout-> addWidget ( m_fontselect ); 323 vertLayout-> addWidget ( m_fontselect );
324 324
325 connect ( m_fontuse, SIGNAL( toggled ( bool )), m_fontselect, SLOT( setEnabled ( bool ))); 325 connect ( m_fontuse, SIGNAL( toggled ( bool )), m_fontselect, SLOT( setEnabled ( bool )));
326 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), 326 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
327 this, SLOT( fontClicked ( const QFont & ))); 327 this, SLOT( fontClicked ( const QFont & )));
328 328
329 return tab; 329 return tab;
330} 330}
331 331
332QWidget *TabDialog::createBgTab ( QWidget *parent ) 332QWidget *TabDialog::createBgTab ( QWidget *parent )
333{ 333{
334 QWidget *tab = new QWidget( parent, "BgTab" ); 334 QWidget *tab = new QWidget( parent, "BgTab" );
335 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 335 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
336 336
337 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 337 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
338 gridLayout-> setColStretch ( 1, 10 ); 338 gridLayout-> setColStretch ( 1, 10 );
339 339
340 QLabel* label = new QLabel( tr( "Type:" ), tab ); 340 QLabel* label = new QLabel( tr( "Type:" ), tab );
341 gridLayout-> addWidget ( label, 0, 0 ); 341 gridLayout-> addWidget ( label, 0, 0 );
342 m_bgtype = new QButtonGroup( tab, "buttongroup" ); 342 m_bgtype = new QButtonGroup( tab, "buttongroup" );
343 m_bgtype-> hide ( ); 343 m_bgtype-> hide ( );
344 m_bgtype-> setExclusive ( true ); 344 m_bgtype-> setExclusive ( true );
345 345
346 QRadioButton *rb; 346 QRadioButton *rb;
347 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); 347 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" );
348 m_bgtype-> insert ( rb, TabConfig::Ruled ); 348 m_bgtype-> insert ( rb, TabConfig::Ruled );
349 gridLayout-> addWidget( rb, 0, 1 ); 349 gridLayout-> addWidget( rb, 0, 1 );
350 350
351 QHBoxLayout *hb = new QHBoxLayout ( ); 351 QHBoxLayout *hb = new QHBoxLayout ( );
352 hb-> setSpacing ( 3 ); 352 hb-> setSpacing ( 3 );
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp
index 4701506..75a181b 100644
--- a/core/settings/security/security.cpp
+++ b/core/settings/security/security.cpp
@@ -1,235 +1,307 @@
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#include "security.h" 20#include "security.h"
21 21
22#include <qpe/qpeapplication.h>
22#include <qpe/config.h> 23#include <qpe/config.h>
23#include <qpe/password.h> 24#include <qpe/password.h>
24#include <qpe/qpedialog.h> 25#include <qpe/qpedialog.h>
25 26
26#include <qcheckbox.h> 27#include <qcheckbox.h>
27#include <qpushbutton.h> 28#include <qpushbutton.h>
28#include <qcombobox.h> 29#include <qcombobox.h>
29#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qfile.h>
32#include <qlistview.h>
33#include <qtextstream.h>
30 34
31Security::Security( QWidget* parent, const char* name, WFlags fl ) 35 Security::Security( QWidget* parent, const char* name, WFlags fl )
32 : SecurityBase( parent, name, TRUE, fl ) 36: SecurityBase( parent, name, TRUE, fl )
33{ 37{
34 valid=FALSE; 38 valid=FALSE;
35 Config cfg("Security"); 39 Config cfg("Security");
36 cfg.setGroup("Passcode"); 40 cfg.setGroup("Passcode");
37 passcode = cfg.readEntry("passcode"); 41 passcode = cfg.readEntry("passcode");
38 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); 42 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE));
39 cfg.setGroup("Sync"); 43 cfg.setGroup("Sync");
40 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 44 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
41 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); 45 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
42 selectNet(auth_peer,auth_peer_bits); 46 selectNet(auth_peer,auth_peer_bits);
43 connect(syncnet, SIGNAL(textChanged(const QString&)), 47 connect(syncnet, SIGNAL(textChanged(const QString&)),
44 this, SLOT(setSyncNet(const QString&))); 48 this, SLOT(setSyncNet(const QString&)));
45 49
46 /* 50 /*
47 cfg.setGroup("Remote"); 51 cfg.setGroup("Remote");
48 if ( telnetAvailable() ) 52 if ( telnetAvailable() )
49 telnet->setChecked(cfg.readEntry("allow_telnet")); 53 telnet->setChecked(cfg.readEntry("allow_telnet"));
50 else 54 else
51 telnet->hide(); 55 telnet->hide();
52
53 if ( sshAvailable() )
54 ssh->setChecked(cfg.readEntry("allow_ssh"));
55 else
56 ssh->hide();
57 */
58 56
57 if ( sshAvailable() )
58 ssh->setChecked(cfg.readEntry("allow_ssh"));
59 else
60 ssh->hide();
61 */
62
63 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
64 Config loginCfg(configFile,Config::File);
65
66 loginCfg.setGroup("General");
67 autoLoginName=loginCfg.readEntry("AutoLogin","");
68
69 if (autoLoginName.stripWhiteSpace().isEmpty()) {
70 autoLogin=false;
71 } else {
72 autoLogin=true;
73 }
74
75
76 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
77 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
59 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); 78 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
60 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); 79 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
80
81 loadUsers();
61 updateGUI(); 82 updateGUI();
62 83
63 dl = new QPEDialogListener(this); 84 dl = new QPEDialogListener(this);
64 showMaximized(); 85 showMaximized();
65} 86}
66 87
67Security::~Security() 88Security::~Security()
68{ 89{
69} 90}
70 91
71 92
72void Security::updateGUI() 93void Security::updateGUI()
73{ 94{
74 bool empty = passcode.isEmpty(); 95 bool empty = passcode.isEmpty();
75 96
76 changepasscode->setText( empty ? tr("Set passcode" ) 97 changepasscode->setText( empty ? tr("Set passcode" )
77 : tr("Change passcode" ) ); 98 : tr("Change passcode" ) );
78 passcode_poweron->setEnabled( !empty ); 99 passcode_poweron->setEnabled( !empty );
79 clearpasscode->setEnabled( !empty ); 100 clearpasscode->setEnabled( !empty );
101
102 autologinToggle->setChecked(autoLogin);
103 userlist->setEnabled(autoLogin);
104
80} 105}
81 106
82 107
83void Security::show() 108void Security::show()
84{ 109{
85 valid=FALSE; 110 valid=FALSE;
86 setEnabled(FALSE); 111 setEnabled(FALSE);
87 SecurityBase::show(); 112 SecurityBase::show();
88 if ( passcode.isEmpty() ) { 113 if ( passcode.isEmpty() ) {
89 // could insist... 114 // could insist...
90 //changePassCode(); 115 //changePassCode();
91 //if ( passcode.isEmpty() ) 116 //if ( passcode.isEmpty() )
92 //reject(); 117 //reject();
93 } else { 118 } else {
94 QString pc = enterPassCode(tr("Enter passcode")); 119 QString pc = enterPassCode(tr("Enter passcode"));
95 if ( pc != passcode ) { 120 if ( pc != passcode ) {
96 QMessageBox::critical(this, tr("Passcode incorrect"), 121 QMessageBox::critical(this, tr("Passcode incorrect"),
97 tr("The passcode entered is incorrect.\nAccess denied")); 122 tr("The passcode entered is incorrect.\nAccess denied"));
98 reject(); 123 reject();
99 return; 124 return;
100 } 125 }
101 } 126 }
102 setEnabled(TRUE); 127 setEnabled(TRUE);
103 valid=TRUE; 128 valid=TRUE;
104} 129}
105 130
106void Security::accept() 131void Security::accept()
107{ 132{
108 applySecurity(); 133 applySecurity();
109 QDialog::accept(); 134 QDialog::accept();
110} 135}
111 136
112void Security::done(int r) 137void Security::done(int r)
113{ 138{
114 QDialog::done(r); 139 QDialog::done(r);
115 close(); 140 close();
116} 141}
117 142
118void Security::selectNet(int auth_peer,int auth_peer_bits) 143void Security::selectNet(int auth_peer,int auth_peer_bits)
119{ 144{
120 QString sn; 145 QString sn;
121 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 146 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
122 sn = tr("Any"); 147 sn = tr("Any");
123 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 148 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
124 sn = tr("None"); 149 sn = tr("None");
125 } else { 150 } else {
126 sn = 151 sn =
127 QString::number((auth_peer>>24)&0xff) + "." 152 QString::number((auth_peer>>24)&0xff) + "."
128 + QString::number((auth_peer>>16)&0xff) + "." 153 + QString::number((auth_peer>>16)&0xff) + "."
129 + QString::number((auth_peer>>8)&0xff) + "." 154 + QString::number((auth_peer>>8)&0xff) + "."
130 + QString::number((auth_peer>>0)&0xff) + "/" 155 + QString::number((auth_peer>>0)&0xff) + "/"
131 + QString::number(auth_peer_bits); 156 + QString::number(auth_peer_bits);
132 } 157 }
133 for (int i=0; i<syncnet->count(); i++) { 158 for (int i=0; i<syncnet->count(); i++) {
134 if ( syncnet->text(i).left(sn.length()) == sn ) { 159 if ( syncnet->text(i).left(sn.length()) == sn ) {
135 syncnet->setCurrentItem(i); 160 syncnet->setCurrentItem(i);
136 return; 161 return;
137 } 162 }
138 } 163 }
139 qDebug("No match for \"%s\"",sn.latin1()); 164 qDebug("No match for \"%s\"",sn.latin1());
140} 165}
141 166
142void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 167void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
143{ 168{
144 auth_peer=0; 169 auth_peer=0;
145 if ( sn == tr("Any") ) { 170 if ( sn == tr("Any") ) {
146 auth_peer = 0; 171 auth_peer = 0;
147 auth_peer_bits = 0; 172 auth_peer_bits = 0;
148 } else if ( sn == tr("None") ) { 173 } else if ( sn == tr("None") ) {
149 auth_peer = 0; 174 auth_peer = 0;
150 auth_peer_bits = 32; 175 auth_peer_bits = 32;
151 } else { 176 } else {
152 int x=0; 177 int x=0;
153 for (int i=0; i<4; i++) { 178 for (int i=0; i<4; i++) {
154 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 179 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
155 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 180 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
156 x = nx+1; 181 x = nx+1;
157 } 182 }
158 uint n = (uint)sn.find(' ',x)-x; 183 uint n = (uint)sn.find(' ',x)-x;
159 auth_peer_bits = sn.mid(x,n).toInt(); 184 auth_peer_bits = sn.mid(x,n).toInt();
160 } 185 }
161} 186}
162 187
188void Security::loadUsers ( void )
189{
190 QFile passwd("/etc/passwd");
191 if ( passwd.open(IO_ReadOnly) ) {
192 QTextStream t( &passwd );
193 QString s;
194 QStringList account;
195 while ( !t.eof() ) {
196 account = QStringList::split(':',t.readLine());
197
198 // Hide disabled accounts
199 if (*account.at(1)!="*") {
200
201 userlist->insertItem(*account.at(0));
202 // Highlight this item if it is set to autologinToggle
203 if ( *account.at(0) == autoLoginName)
204 userlist->setCurrentItem(userlist->count()-1);
205 }
206 }
207 passwd.close();
208 }
209
210}
211void Security::toggleAutoLogin(bool val)
212{
213 autoLogin=val;
214 userlist->setEnabled(val);
215 if (!autoLogin)
216 autoLoginName=userlist->currentText();
217}
163void Security::setSyncNet(const QString& sn) 218void Security::setSyncNet(const QString& sn)
164{ 219{
165 int auth_peer,auth_peer_bits; 220 int auth_peer,auth_peer_bits;
166 parseNet(sn,auth_peer,auth_peer_bits); 221 parseNet(sn,auth_peer,auth_peer_bits);
167 selectNet(auth_peer,auth_peer_bits); 222 selectNet(auth_peer,auth_peer_bits);
168} 223}
169 224
170void Security::applySecurity() 225void Security::applySecurity()
171{ 226{
172 if ( valid ) { 227 if ( valid ) {
173 Config cfg("Security"); 228 Config cfg("Security");
174 cfg.setGroup("Passcode"); 229 cfg.setGroup("Passcode");
175 cfg.writeEntry("passcode",passcode); 230 cfg.writeEntry("passcode",passcode);
176 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); 231 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked());
177 cfg.setGroup("Sync"); 232 cfg.setGroup("Sync");
178 int auth_peer=0; 233 int auth_peer=0;
179 int auth_peer_bits; 234 int auth_peer_bits;
180 QString sn = syncnet->currentText(); 235 QString sn = syncnet->currentText();
181 parseNet(sn,auth_peer,auth_peer_bits); 236 parseNet(sn,auth_peer,auth_peer_bits);
182 cfg.writeEntry("auth_peer",auth_peer); 237 cfg.writeEntry("auth_peer",auth_peer);
183 cfg.writeEntry("auth_peer_bits",auth_peer_bits); 238 cfg.writeEntry("auth_peer_bits",auth_peer_bits);
184 /* 239 /*
185 cfg.setGroup("Remote"); 240 cfg.setGroup("Remote");
186 if ( telnetAvailable() ) 241 if ( telnetAvailable() )
187 cfg.writeEntry("allow_telnet",telnet->isChecked()); 242 cfg.writeEntry("allow_telnet",telnet->isChecked());
188 if ( sshAvailable() ) 243 if ( sshAvailable() )
189 cfg.writeEntry("allow_ssh",ssh->isChecked()); 244 cfg.writeEntry("allow_ssh",ssh->isChecked());
190 // ### write ssh/telnet sys config files 245 // ### write ssh/telnet sys config files
191 */ 246 */
247
248 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
249 Config loginCfg(configFile,Config::File);
250 loginCfg.setGroup("General");
251
252 if (autoLogin) {
253 loginCfg.writeEntry("AutoLogin",autoLoginName);
254 } else {
255 loginCfg.removeEntry("AutoLogin");
256 }
257
192 } 258 }
193} 259}
194 260
261void Security::changeLoginName( int idx )
262{
263 autoLoginName = userlist->text(idx);;
264 updateGUI();
265}
266
195void Security::changePassCode() 267void Security::changePassCode()
196{ 268{
197 QString new1; 269 QString new1;
198 QString new2; 270 QString new2;
199 271
200 do { 272 do {
201 new1 = enterPassCode(tr("Enter new passcode")); 273 new1 = enterPassCode(tr("Enter new passcode"));
202 if ( new1.isNull() ) 274 if ( new1.isNull() )
203 return; 275 return;
204 new2 = enterPassCode(tr("Re-enter new passcode")); 276 new2 = enterPassCode(tr("Re-enter new passcode"));
205 if ( new2.isNull() ) 277 if ( new2.isNull() )
206 return; 278 return;
207 } while (new1 != new2); 279 } while (new1 != new2);
208 280
209 passcode = new1; 281 passcode = new1;
210 updateGUI(); 282 updateGUI();
211} 283}
212 284
213void Security::clearPassCode() 285void Security::clearPassCode()
214{ 286{
215 passcode = QString::null; 287 passcode = QString::null;
216 updateGUI(); 288 updateGUI();
217} 289}
218 290
219 291
220QString Security::enterPassCode(const QString& prompt) 292QString Security::enterPassCode(const QString& prompt)
221{ 293{
222 return Password::getPassword(prompt); 294 return Password::getPassword(prompt);
223} 295}
224 296
225bool Security::telnetAvailable() const 297bool Security::telnetAvailable() const
226{ 298{
227 // ### not implemented 299 // ### not implemented
228 return FALSE; 300 return FALSE;
229} 301}
230 302
231bool Security::sshAvailable() const 303bool Security::sshAvailable() const
232{ 304{
233 // ### not implemented 305 // ### not implemented
234 return FALSE; 306 return FALSE;
235} 307}
diff --git a/core/settings/security/security.h b/core/settings/security/security.h
index efc83a2..2f18f91 100644
--- a/core/settings/security/security.h
+++ b/core/settings/security/security.h
@@ -1,64 +1,70 @@
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 SECURITY_H 20#ifndef SECURITY_H
21#define SECURITY_H 21#define SECURITY_H
22 22
23#include "securitybase.h" 23#include "securitybase.h"
24 24
25class QPEDialogListener; 25class QPEDialogListener;
26 26
27class Security : public SecurityBase 27class Security : public SecurityBase
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: 31public:
32 Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 32 Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 ~Security(); 33 ~Security();
34 34
35 void show(); 35 void show();
36 36
37protected: 37protected:
38 void accept(); 38 void accept();
39 void applySecurity(); 39 void applySecurity();
40 void done(int); 40 void done(int);
41 41
42private slots: 42private slots:
43 void changePassCode(); 43 void changePassCode();
44 void clearPassCode(); 44 void clearPassCode();
45 void setSyncNet(const QString&); 45 void setSyncNet(const QString&);
46 void changeLoginName(int);
47 void toggleAutoLogin(bool);
48
46 49
47private: 50private:
51 void loadUsers(void);
48 bool telnetAvailable() const; 52 bool telnetAvailable() const;
49 bool sshAvailable() const; 53 bool sshAvailable() const;
50 void updateGUI(); 54 void updateGUI();
51 55
52 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 56 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
53 void selectNet(int auth_peer,int auth_peer_bits); 57 void selectNet(int auth_peer,int auth_peer_bits);
54 58
55 QString enterPassCode(const QString&); 59 QString enterPassCode(const QString&);
56 QString passcode; 60 QString passcode;
57 bool valid; 61 bool valid;
62 bool autoLogin;
63 QString autoLoginName;
58 64
59 QPEDialogListener *dl; 65 QPEDialogListener *dl;
60}; 66};
61 67
62 68
63#endif // SECURITY_H 69#endif // SECURITY_H
64 70
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui
index c2a8953..da25f39 100644
--- a/core/settings/security/securitybase.ui
+++ b/core/settings/security/securitybase.ui
@@ -1,215 +1,412 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>SecurityBase</class> 2<class>SecurityBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>SecurityBase</cstring> 7 <cstring>SecurityBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>277</width> 14 <width>329</width>
15 <height>328</height> 15 <height>483</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Security Settings</string> 20 <string>Security Settings</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <grid> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>3</number> 31 <number>0</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>3</number> 35 <number>0</number>
36 </property> 36 </property>
37 <widget row="0" column="0" > 37 <widget>
38 <class>QLayoutWidget</class> 38 <class>QTabWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>Layout1</cstring> 41 <cstring>TabWidget2</cstring>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutSpacing</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <hbox> 46 <widget>
47 <property stdset="1"> 47 <class>QWidget</class>
48 <name>margin</name>
49 <number>0</number>
50 </property>
51 <property stdset="1"> 48 <property stdset="1">
52 <name>spacing</name> 49 <name>name</name>
53 <number>-1</number> 50 <cstring>tab</cstring>
54 </property> 51 </property>
55 <widget> 52 <attribute>
56 <class>QPushButton</class> 53 <name>title</name>
54 <string>Passcode</string>
55 </attribute>
56 <vbox>
57 <property stdset="1"> 57 <property stdset="1">
58 <name>name</name> 58 <name>margin</name>
59 <cstring>changepasscode</cstring> 59 <number>6</number>
60 </property> 60 </property>
61 <property stdset="1"> 61 <property stdset="1">
62 <name>text</name> 62 <name>spacing</name>
63 <string>Change passcode</string> 63 <number>6</number>
64 </property> 64 </property>
65 </widget> 65 <widget>
66 <widget> 66 <class>QGroupBox</class>
67 <class>QPushButton</class> 67 <property stdset="1">
68 <name>name</name>
69 <cstring>GroupBox4</cstring>
70 </property>
71 <property stdset="1">
72 <name>title</name>
73 <string>Passcode</string>
74 </property>
75 <vbox>
76 <property stdset="1">
77 <name>margin</name>
78 <number>11</number>
79 </property>
80 <property stdset="1">
81 <name>spacing</name>
82 <number>6</number>
83 </property>
84 <widget>
85 <class>QLayoutWidget</class>
86 <property stdset="1">
87 <name>name</name>
88 <cstring>Layout1</cstring>
89 </property>
90 <property>
91 <name>layoutSpacing</name>
92 </property>
93 <hbox>
94 <property stdset="1">
95 <name>margin</name>
96 <number>0</number>
97 </property>
98 <property stdset="1">
99 <name>spacing</name>
100 <number>-1</number>
101 </property>
102 <widget>
103 <class>QPushButton</class>
104 <property stdset="1">
105 <name>name</name>
106 <cstring>changepasscode</cstring>
107 </property>
108 <property stdset="1">
109 <name>text</name>
110 <string>Change passcode</string>
111 </property>
112 </widget>
113 <widget>
114 <class>QPushButton</class>
115 <property stdset="1">
116 <name>name</name>
117 <cstring>clearpasscode</cstring>
118 </property>
119 <property stdset="1">
120 <name>text</name>
121 <string>Clear passcode</string>
122 </property>
123 </widget>
124 </hbox>
125 </widget>
126 <widget>
127 <class>QCheckBox</class>
128 <property stdset="1">
129 <name>name</name>
130 <cstring>passcode_poweron</cstring>
131 </property>
132 <property stdset="1">
133 <name>text</name>
134 <string>Require pass code at power-on</string>
135 </property>
136 </widget>
137 <widget>
138 <class>QLabel</class>
139 <property stdset="1">
140 <name>name</name>
141 <cstring>TextLabel1</cstring>
142 </property>
143 <property stdset="1">
144 <name>sizePolicy</name>
145 <sizepolicy>
146 <hsizetype>5</hsizetype>
147 <vsizetype>7</vsizetype>
148 </sizepolicy>
149 </property>
150 <property stdset="1">
151 <name>text</name>
152 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
153 </property>
154 <property stdset="1">
155 <name>textFormat</name>
156 <enum>RichText</enum>
157 </property>
158 <property stdset="1">
159 <name>alignment</name>
160 <set>AlignTop|AlignLeft</set>
161 </property>
162 <property>
163 <name>vAlign</name>
164 </property>
165 </widget>
166 </vbox>
167 </widget>
168 <spacer>
169 <property>
170 <name>name</name>
171 <cstring>Spacer3</cstring>
172 </property>
173 <property stdset="1">
174 <name>orientation</name>
175 <enum>Vertical</enum>
176 </property>
177 <property stdset="1">
178 <name>sizeType</name>
179 <enum>Expanding</enum>
180 </property>
181 <property>
182 <name>sizeHint</name>
183 <size>
184 <width>20</width>
185 <height>20</height>
186 </size>
187 </property>
188 </spacer>
189 </vbox>
190 </widget>
191 <widget>
192 <class>QWidget</class>
193 <property stdset="1">
194 <name>name</name>
195 <cstring>tab</cstring>
196 </property>
197 <attribute>
198 <name>title</name>
199 <string>Login</string>
200 </attribute>
201 <vbox>
68 <property stdset="1"> 202 <property stdset="1">
69 <name>name</name> 203 <name>margin</name>
70 <cstring>clearpasscode</cstring> 204 <number>6</number>
71 </property> 205 </property>
72 <property stdset="1"> 206 <property stdset="1">
73 <name>text</name> 207 <name>spacing</name>
74 <string>Clear passcode</string> 208 <number>6</number>
75 </property> 209 </property>
76 </widget> 210 <widget>
77 </hbox> 211 <class>QGroupBox</class>
78 </widget> 212 <property stdset="1">
79 <widget row="1" column="0" > 213 <name>name</name>
80 <class>QCheckBox</class> 214 <cstring>GroupBox3</cstring>
81 <property stdset="1"> 215 </property>
82 <name>name</name> 216 <property stdset="1">
83 <cstring>passcode_poweron</cstring> 217 <name>title</name>
84 </property> 218 <string>Login</string>
85 <property stdset="1"> 219 </property>
86 <name>text</name> 220 <vbox>
87 <string>Require pass code at power-on</string> 221 <property stdset="1">
88 </property> 222 <name>margin</name>
89 </widget> 223 <number>11</number>
90 <widget row="3" column="0" > 224 </property>
91 <class>QTabWidget</class> 225 <property stdset="1">
92 <property stdset="1"> 226 <name>spacing</name>
93 <name>name</name> 227 <number>6</number>
94 <cstring>TabWidget2</cstring> 228 </property>
95 </property> 229 <widget>
230 <class>QCheckBox</class>
231 <property stdset="1">
232 <name>name</name>
233 <cstring>autologinToggle</cstring>
234 </property>
235 <property stdset="1">
236 <name>text</name>
237 <string>Login Automatically</string>
238 </property>
239 </widget>
240 <widget>
241 <class>QComboBox</class>
242 <property stdset="1">
243 <name>name</name>
244 <cstring>userlist</cstring>
245 </property>
246 </widget>
247 </vbox>
248 </widget>
249 <spacer>
250 <property>
251 <name>name</name>
252 <cstring>Spacer2</cstring>
253 </property>
254 <property stdset="1">
255 <name>orientation</name>
256 <enum>Vertical</enum>
257 </property>
258 <property stdset="1">
259 <name>sizeType</name>
260 <enum>Expanding</enum>
261 </property>
262 <property>
263 <name>sizeHint</name>
264 <size>
265 <width>20</width>
266 <height>20</height>
267 </size>
268 </property>
269 </spacer>
270 </vbox>
271 </widget>
96 <widget> 272 <widget>
97 <class>QWidget</class> 273 <class>QWidget</class>
98 <property stdset="1"> 274 <property stdset="1">
99 <name>name</name> 275 <name>name</name>
100 <cstring>tab</cstring> 276 <cstring>tab</cstring>
101 </property> 277 </property>
102 <attribute> 278 <attribute>
103 <name>title</name> 279 <name>title</name>
104 <string>Sync</string> 280 <string>Sync</string>
105 </attribute> 281 </attribute>
106 <vbox> 282 <vbox>
107 <property stdset="1"> 283 <property stdset="1">
108 <name>margin</name> 284 <name>margin</name>
109 <number>11</number> 285 <number>6</number>
110 </property> 286 </property>
111 <property stdset="1"> 287 <property stdset="1">
112 <name>spacing</name> 288 <name>spacing</name>
113 <number>6</number> 289 <number>6</number>
114 </property> 290 </property>
115 <widget> 291 <widget>
116 <class>QLabel</class> 292 <class>QGroupBox</class>
117 <property stdset="1"> 293 <property stdset="1">
118 <name>name</name> 294 <name>name</name>
119 <cstring>TextLabel1_2</cstring> 295 <cstring>GroupBox2</cstring>
120 </property> 296 </property>
121 <property stdset="1"> 297 <property stdset="1">
122 <name>text</name> 298 <name>title</name>
123 <string>Accept sync from network:</string> 299 <string>Sync</string>
124 </property> 300 </property>
125 </widget> 301 <vbox>
126 <widget> 302 <property stdset="1">
127 <class>QComboBox</class> 303 <name>margin</name>
128 <item> 304 <number>11</number>
129 <property>
130 <name>text</name>
131 <string>192.168.129.0/24 (default)</string>
132 </property>
133 </item>
134 <item>
135 <property>
136 <name>text</name>
137 <string>192.168.1.0/24</string>
138 </property>
139 </item>
140 <item>
141 <property>
142 <name>text</name>
143 <string>192.168.0.0/16</string>
144 </property>
145 </item>
146 <item>
147 <property>
148 <name>text</name>
149 <string>172.16.0.0/12</string>
150 </property>
151 </item>
152 <item>
153 <property>
154 <name>text</name>
155 <string>10.0.0.0/8</string>
156 </property>
157 </item>
158 <item>
159 <property>
160 <name>text</name>
161 <string>1.0.0.0/8</string>
162 </property> 305 </property>
163 </item> 306 <property stdset="1">
164 <item> 307 <name>spacing</name>
165 <property> 308 <number>6</number>
166 <name>text</name>
167 <string>Any</string>
168 </property> 309 </property>
169 </item> 310 <widget>
170 <item> 311 <class>QLabel</class>
171 <property> 312 <property stdset="1">
172 <name>text</name> 313 <name>name</name>
173 <string>None</string> 314 <cstring>TextLabel1_2</cstring>
174 </property> 315 </property>
175 </item> 316 <property stdset="1">
176 <property stdset="1"> 317 <name>text</name>
318 <string>Accept sync from network:</string>
319 </property>
320 <property stdset="1">
321 <name>textFormat</name>
322 <enum>RichText</enum>
323 </property>
324 </widget>
325 <widget>
326 <class>QComboBox</class>
327 <item>
328 <property>
329 <name>text</name>
330 <string>192.168.129.0/24 (default)</string>
331 </property>
332 </item>
333 <item>
334 <property>
335 <name>text</name>
336 <string>192.168.1.0/24</string>
337 </property>
338 </item>
339 <item>
340 <property>
341 <name>text</name>
342 <string>192.168.0.0/16</string>
343 </property>
344 </item>
345 <item>
346 <property>
347 <name>text</name>
348 <string>172.16.0.0/12</string>
349 </property>
350 </item>
351 <item>
352 <property>
353 <name>text</name>
354 <string>10.0.0.0/8</string>
355 </property>
356 </item>
357 <item>
358 <property>
359 <name>text</name>
360 <string>1.0.0.0/8</string>
361 </property>
362 </item>
363 <item>
364 <property>
365 <name>text</name>
366 <string>Any</string>
367 </property>
368 </item>
369 <item>
370 <property>
371 <name>text</name>
372 <string>None</string>
373 </property>
374 </item>
375 <property stdset="1">
376 <name>name</name>
377 <cstring>syncnet</cstring>
378 </property>
379 <property stdset="1">
380 <name>editable</name>
381 <bool>true</bool>
382 </property>
383 </widget>
384 </vbox>
385 </widget>
386 <spacer>
387 <property>
177 <name>name</name> 388 <name>name</name>
178 <cstring>syncnet</cstring> 389 <cstring>Spacer1</cstring>
179 </property> 390 </property>
180 <property stdset="1"> 391 <property stdset="1">
181 <name>editable</name> 392 <name>orientation</name>
182 <bool>true</bool> 393 <enum>Vertical</enum>
183 </property> 394 </property>
184 </widget> 395 <property stdset="1">
396 <name>sizeType</name>
397 <enum>Expanding</enum>
398 </property>
399 <property>
400 <name>sizeHint</name>
401 <size>
402 <width>20</width>
403 <height>20</height>
404 </size>
405 </property>
406 </spacer>
185 </vbox> 407 </vbox>
186 </widget> 408 </widget>
187 </widget> 409 </widget>
188 <widget row="2" column="0" > 410 </vbox>
189 <class>QLabel</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>TextLabel1</cstring>
193 </property>
194 <property stdset="1">
195 <name>sizePolicy</name>
196 <sizepolicy>
197 <hsizetype>5</hsizetype>
198 <vsizetype>7</vsizetype>
199 </sizepolicy>
200 </property>
201 <property stdset="1">
202 <name>text</name>
203 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
204 </property>
205 <property stdset="1">
206 <name>alignment</name>
207 <set>AlignTop|AlignLeft</set>
208 </property>
209 <property>
210 <name>vAlign</name>
211 </property>
212 </widget>
213 </grid>
214</widget> 411</widget>
215</UI> 412</UI>