summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/custom-ipaq.h5
-rw-r--r--library/custom-ramses.h3
-rw-r--r--library/custom-sharp.h4
-rw-r--r--library/custom-simpad.h4
-rw-r--r--library/qpeapplication.cpp10
-rw-r--r--library/storage.cpp2
6 files changed, 19 insertions, 9 deletions
diff --git a/library/custom-ipaq.h b/library/custom-ipaq.h
index a9319fa..8321199 100644
--- a/library/custom-ipaq.h
+++ b/library/custom-ipaq.h
@@ -1,21 +1,24 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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 QPE_NEED_CALIBRATION \ No newline at end of file 21#define QPE_NEED_CALIBRATION
22#define OPIE_SOUND_FRAGMENT_SHIFT 14
23#define USE_REALTIME_AUDIO_THREAD
24#define OPIE_NEW_MALLOC
diff --git a/library/custom-ramses.h b/library/custom-ramses.h
index 9104931..5a1abe4 100644
--- a/library/custom-ramses.h
+++ b/library/custom-ramses.h
@@ -1,69 +1,72 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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 QPE_NEED_CALIBRATION 21#define QPE_NEED_CALIBRATION
22#define QPE_HAVE_TOGGLELIGHT 22#define QPE_HAVE_TOGGLELIGHT
23#define QPE_STARTMENU 23#define QPE_STARTMENU
24#define USE_REALTIME_AUDIO_THREAD
25#define OPIE_NEW_MALLOC
26
24 27
25#include <unistd.h> 28#include <unistd.h>
26#include <stdio.h> 29#include <stdio.h>
27#include <signal.h> 30#include <signal.h>
28#include <fcntl.h> 31#include <fcntl.h>
29#include <sys/ioctl.h> 32#include <sys/ioctl.h>
30 33
31#define QPE_HAVE_MEMALERTER 34#define QPE_HAVE_MEMALERTER
32 35
33#define QPE_MEMALERTER_IMPL \ 36#define QPE_MEMALERTER_IMPL \
34static void sig_handler(int sig) \ 37static void sig_handler(int sig) \
35{ \ 38{ \
36 switch (sig) { \ 39 switch (sig) { \
37 case SIGHUP: \ 40 case SIGHUP: \
38 memstate = VeryLow; \ 41 memstate = VeryLow; \
39 break; \ 42 break; \
40 case SIGUSR1: \ 43 case SIGUSR1: \
41 memstate = Normal; \ 44 memstate = Normal; \
42 break; \ 45 break; \
43 case SIGUSR2: \ 46 case SIGUSR2: \
44 memstate = Low; \ 47 memstate = Low; \
45 break; \ 48 break; \
46 } \ 49 } \
47} \ 50} \
48static void initMemalerter() \ 51static void initMemalerter() \
49{ \ 52{ \
50 struct sigaction sa; \ 53 struct sigaction sa; \
51 memset(&sa, '\0', sizeof sa); \ 54 memset(&sa, '\0', sizeof sa); \
52 sa.sa_handler = sig_handler; \ 55 sa.sa_handler = sig_handler; \
53 sa.sa_flags = SA_RESTART; \ 56 sa.sa_flags = SA_RESTART; \
54 if (sigaction(SIGHUP, &sa, NULL) < 0) { \ 57 if (sigaction(SIGHUP, &sa, NULL) < 0) { \
55 return; \ 58 return; \
56 } \ 59 } \
57 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ 60 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
58 return; \ 61 return; \
59 } \ 62 } \
60 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ 63 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
61 return; \ 64 return; \
62 } \ 65 } \
63 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ 66 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
64 \ 67 \
65 if (!fo) \ 68 if (!fo) \
66 return; \ 69 return; \
67 fprintf(fo, "qpe\n"); \ 70 fprintf(fo, "qpe\n"); \
68 fclose(fo); \ 71 fclose(fo); \
69} 72}
diff --git a/library/custom-sharp.h b/library/custom-sharp.h
index 3936875..b0e67b8 100644
--- a/library/custom-sharp.h
+++ b/library/custom-sharp.h
@@ -1,98 +1,102 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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 QPE_NEED_CALIBRATION 21#define QPE_NEED_CALIBRATION
22#define QPE_OWNAPM 22#define QPE_OWNAPM
23#define QPE_HAVE_TOGGLELIGHT 23#define QPE_HAVE_TOGGLELIGHT
24#define QPE_NOCIBAUD 24#define QPE_NOCIBAUD
25#define QPE_STARTMENU 25#define QPE_STARTMENU
26#define OPIE_NEW_MALLOC
27#define USE_REALTIME_AUDIO_THREAD
28#define OPIE_NO_SOUND_PCM_READ_BITS
29
26#include <asm/sharp_apm.h> 30#include <asm/sharp_apm.h>
27#ifndef APM_IOC_BATTERY_BACK_CHK 31#ifndef APM_IOC_BATTERY_BACK_CHK
28#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) 32#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
29#endif 33#endif
30#ifndef APM_IOC_BATTERY_MAIN_CHK 34#ifndef APM_IOC_BATTERY_MAIN_CHK
31#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) 35#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33)
32#endif 36#endif
33 37
34#include <unistd.h> 38#include <unistd.h>
35#include <stdio.h> 39#include <stdio.h>
36#include <signal.h> 40#include <signal.h>
37#include <fcntl.h> 41#include <fcntl.h>
38#include <sys/ioctl.h> 42#include <sys/ioctl.h>
39 43
40 44
41#include <sys/ioctl.h> 45#include <sys/ioctl.h>
42#include <asm/sharp_char.h> 46#include <asm/sharp_char.h>
43 47
44#define QPE_HAVE_MEMALERTER 48#define QPE_HAVE_MEMALERTER
45 49
46#define QPE_MEMALERTER_IMPL \ 50#define QPE_MEMALERTER_IMPL \
47static void sig_handler(int sig) \ 51static void sig_handler(int sig) \
48{ \ 52{ \
49 switch (sig) { \ 53 switch (sig) { \
50 case SIGHUP: \ 54 case SIGHUP: \
51 memstate = VeryLow; \ 55 memstate = VeryLow; \
52 break; \ 56 break; \
53 case SIGUSR1: \ 57 case SIGUSR1: \
54 memstate = Normal; \ 58 memstate = Normal; \
55 break; \ 59 break; \
56 case SIGUSR2: \ 60 case SIGUSR2: \
57 memstate = Low; \ 61 memstate = Low; \
58 break; \ 62 break; \
59 } \ 63 } \
60} \ 64} \
61static void initMemalerter() \ 65static void initMemalerter() \
62{ \ 66{ \
63 struct sigaction sa; \ 67 struct sigaction sa; \
64 memset(&sa, '\0', sizeof sa); \ 68 memset(&sa, '\0', sizeof sa); \
65 sa.sa_handler = sig_handler; \ 69 sa.sa_handler = sig_handler; \
66 sa.sa_flags = SA_RESTART; \ 70 sa.sa_flags = SA_RESTART; \
67 if (sigaction(SIGHUP, &sa, NULL) < 0) { \ 71 if (sigaction(SIGHUP, &sa, NULL) < 0) { \
68 return; \ 72 return; \
69 } \ 73 } \
70 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ 74 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
71 return; \ 75 return; \
72 } \ 76 } \
73 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ 77 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
74 return; \ 78 return; \
75 } \ 79 } \
76 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ 80 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
77 \ 81 \
78 if (!fo) \ 82 if (!fo) \
79 return; \ 83 return; \
80 fprintf(fo, "qpe\n"); \ 84 fprintf(fo, "qpe\n"); \
81 fclose(fo); \ 85 fclose(fo); \
82} 86}
83 87
84#define QPE_INITIAL_NUMLOCK_STATE \ 88#define QPE_INITIAL_NUMLOCK_STATE \
85{ \ 89{ \
86 bool numLock = FALSE; \ 90 bool numLock = FALSE; \
87 sharp_kbdctl_modifstat st; \ 91 sharp_kbdctl_modifstat st; \
88 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ 92 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \
89 if( dev >= 0 ) { \ 93 if( dev >= 0 ) { \
90 memset(&st, 0, sizeof(st)); \ 94 memset(&st, 0, sizeof(st)); \
91 st.which = 3; \ 95 st.which = 3; \
92 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ 96 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \
93 if( !ret ) \ 97 if( !ret ) \
94 numLock = (bool)st.stat; \ 98 numLock = (bool)st.stat; \
95 ::close(dev); \ 99 ::close(dev); \
96 } \ 100 } \
97 return numLock; \ 101 return numLock; \
98} 102}
diff --git a/library/custom-simpad.h b/library/custom-simpad.h
index 3872dfd..c951296 100644
--- a/library/custom-simpad.h
+++ b/library/custom-simpad.h
@@ -1,7 +1,9 @@
1/* 1/*
2 * GPLv2 only zecke@handhelds.org 2 * GPLv2 only zecke@handhelds.org
3 hOlgAr 3 hOlgAr
4 */ 4 */
5 5
6 6
7#define QPE_NEED_CALIBRATION \ No newline at end of file 7#define QPE_NEED_CALIBRATION
8#define OPIE_NEW_MALLOC
9#define USE_REALTIME_AUDIO_THREAD
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index feba8b6..cd1c62e 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,362 +1,362 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 23#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
24#include <qfile.h> 24#include <qfile.h>
25#include <qqueue.h> 25#include <qqueue.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#ifndef QT_NO_COP 27#ifndef QT_NO_COP
28#if QT_VERSION <= 231 28#if QT_VERSION <= 231
29#define private public 29#define private public
30#define sendLocally processEvent 30#define sendLocally processEvent
31#include "qcopenvelope_qws.h" 31#include "qcopenvelope_qws.h"
32#undef private 32#undef private
33#else 33#else
34#include "qcopenvelope_qws.h" 34#include "qcopenvelope_qws.h"
35#endif 35#endif
36#endif 36#endif
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#endif 38#endif
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qpalette.h> 40#include <qpalette.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qtextcodec.h> 48#include <qtextcodec.h>
49#include <qevent.h> 49#include <qevent.h>
50#include <qtooltip.h> 50#include <qtooltip.h>
51#include <qsignal.h> 51#include <qsignal.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53#include <qwidgetlist.h> 53#include <qwidgetlist.h>
54#include <qpixmapcache.h> 54#include <qpixmapcache.h>
55 55
56#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 56#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
57#define QTOPIA_INTERNAL_INITAPP 57#define QTOPIA_INTERNAL_INITAPP
58#include "qpeapplication.h" 58#include "qpeapplication.h"
59#include "qpestyle.h" 59#include "qpestyle.h"
60#include "styleinterface.h" 60#include "styleinterface.h"
61#if QT_VERSION >= 300 61#if QT_VERSION >= 300
62#include <qstylefactory.h> 62#include <qstylefactory.h>
63#else 63#else
64#include <qplatinumstyle.h> 64#include <qplatinumstyle.h>
65#include <qwindowsstyle.h> 65#include <qwindowsstyle.h>
66#include <qmotifstyle.h> 66#include <qmotifstyle.h>
67#include <qmotifplusstyle.h> 67#include <qmotifplusstyle.h>
68#include "lightstyle.h" 68#include "lightstyle.h"
69 69
70#include <qpe/qlibrary.h> 70#include <qpe/qlibrary.h>
71#endif 71#endif
72#include "global.h" 72#include "global.h"
73#include "resource.h" 73#include "resource.h"
74#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 74#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
75#include "qutfcodec.h" 75#include "qutfcodec.h"
76#endif 76#endif
77#include "config.h" 77#include "config.h"
78#include "network.h" 78#include "network.h"
79#ifdef QWS 79#ifdef QWS
80#include "fontmanager.h" 80#include "fontmanager.h"
81#endif 81#endif
82 82
83#include "alarmserver.h" 83#include "alarmserver.h"
84#include "applnk.h" 84#include "applnk.h"
85#include "qpemenubar.h" 85#include "qpemenubar.h"
86#include "textcodecinterface.h" 86#include "textcodecinterface.h"
87#include "imagecodecinterface.h" 87#include "imagecodecinterface.h"
88 88
89#include <unistd.h> 89#include <unistd.h>
90#include <sys/file.h> 90#include <sys/file.h>
91#include <sys/ioctl.h> 91#include <sys/ioctl.h>
92#include <sys/soundcard.h> 92#include <sys/soundcard.h>
93 93
94#include "qt_override_p.h" 94#include "qt_override_p.h"
95 95
96 96
97class QPEApplicationData 97class QPEApplicationData
98{ 98{
99public: 99public:
100 QPEApplicationData ( ) 100 QPEApplicationData ( )
101 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 101 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
102 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 102 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
103 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) 103 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 )
104 104
105 {} 105 {}
106 106
107 int presstimer; 107 int presstimer;
108 QWidget* presswidget; 108 QWidget* presswidget;
109 QPoint presspos; 109 QPoint presspos;
110 110
111 bool rightpressed : 1; 111 bool rightpressed : 1;
112 bool kbgrabbed : 1; 112 bool kbgrabbed : 1;
113 bool notbusysent : 1; 113 bool notbusysent : 1;
114 bool preloaded : 1; 114 bool preloaded : 1;
115 bool forceshow : 1; 115 bool forceshow : 1;
116 bool nomaximize : 1; 116 bool nomaximize : 1;
117 bool keep_running : 1; 117 bool keep_running : 1;
118 bool qcopQok : 1; 118 bool qcopQok : 1;
119 119
120 120
121 QStringList langs; 121 QStringList langs;
122 QString appName; 122 QString appName;
123 struct QCopRec 123 struct QCopRec
124 { 124 {
125 QCopRec( const QCString &ch, const QCString &msg, 125 QCopRec( const QCString &ch, const QCString &msg,
126 const QByteArray &d ) : 126 const QByteArray &d ) :
127 channel( ch ), message( msg ), data( d ) 127 channel( ch ), message( msg ), data( d )
128 { } 128 { }
129 129
130 QCString channel; 130 QCString channel;
131 QCString message; 131 QCString message;
132 QByteArray data; 132 QByteArray data;
133 }; 133 };
134 QWidget* qpe_main_widget; 134 QWidget* qpe_main_widget;
135 QGuardedPtr<QWidget> lastraised; 135 QGuardedPtr<QWidget> lastraised;
136 QQueue<QCopRec> qcopq; 136 QQueue<QCopRec> qcopq;
137 QString styleName; 137 QString styleName;
138 QString decorationName; 138 QString decorationName;
139 139
140 void enqueueQCop( const QCString &ch, const QCString &msg, 140 void enqueueQCop( const QCString &ch, const QCString &msg,
141 const QByteArray &data ) 141 const QByteArray &data )
142 { 142 {
143 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 143 qcopq.enqueue( new QCopRec( ch, msg, data ) );
144 } 144 }
145 void sendQCopQ() 145 void sendQCopQ()
146 { 146 {
147 if (!qcopQok ) 147 if (!qcopQok )
148 return; 148 return;
149 149
150 QCopRec * r; 150 QCopRec * r;
151 151
152 while((r=qcopq.dequeue())) { 152 while((r=qcopq.dequeue())) {
153 // remove from queue before sending... 153 // remove from queue before sending...
154 // event loop can come around again before getting 154 // event loop can come around again before getting
155 // back from sendLocally 155 // back from sendLocally
156#ifndef QT_NO_COP 156#ifndef QT_NO_COP
157 QCopChannel::sendLocally( r->channel, r->message, r->data ); 157 QCopChannel::sendLocally( r->channel, r->message, r->data );
158#endif 158#endif
159 159
160 delete r; 160 delete r;
161 } 161 }
162 } 162 }
163 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) 163 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null )
164 { 164 {
165 165
166 // ugly hack, remove that later after finding a sane solution 166 // ugly hack, remove that later after finding a sane solution
167 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 167 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
168 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 168 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
169 // a (physically) large enough display to use the small icons 169 // a (physically) large enough display to use the small icons
170#ifndef QT_QWS_SIMPAD 170#if defined(OPIE_HIGH_RES_SMALL_PHY)
171 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 171 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
172 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 172 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
173 } 173 }
174#endif 174#endif
175 175
176 if ( mw->layout() && mw->inherits("QDialog") ) { 176 if ( mw->layout() && mw->inherits("QDialog") ) {
177 QPEApplication::showDialog((QDialog*)mw, nomaximize); 177 QPEApplication::showDialog((QDialog*)mw, nomaximize);
178 } 178 }
179 else { 179 else {
180#ifdef Q_WS_QWS 180#ifdef Q_WS_QWS
181 if ( !nomaximize ) 181 if ( !nomaximize )
182 mw->showMaximized(); 182 mw->showMaximized();
183 else 183 else
184#endif 184#endif
185 185
186 mw->show(); 186 mw->show();
187 } 187 }
188 } 188 }
189 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 189 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
190 { 190 {
191 /* 191 /*
192 // This works but disable it for now until it is safe to apply 192 // This works but disable it for now until it is safe to apply
193 // What is does is scan the .desktop files of all the apps for 193 // What is does is scan the .desktop files of all the apps for
194 // the applnk that has the corresponding argv[0] as this program 194 // the applnk that has the corresponding argv[0] as this program
195 // then it uses the name stored in the .desktop file as the caption 195 // then it uses the name stored in the .desktop file as the caption
196 // for the main widget. This saves duplicating translations for 196 // for the main widget. This saves duplicating translations for
197 // the app name in the program and in the .desktop files. 197 // the app name in the program and in the .desktop files.
198 198
199 AppLnkSet apps( appsPath ); 199 AppLnkSet apps( appsPath );
200 200
201 QList<AppLnk> appsList = apps.children(); 201 QList<AppLnk> appsList = apps.children();
202 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 202 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
203 if ( (*it)->exec() == appName ) { 203 if ( (*it)->exec() == appName ) {
204 mw->setCaption( (*it)->name() ); 204 mw->setCaption( (*it)->name() );
205 return TRUE; 205 return TRUE;
206 } 206 }
207 } 207 }
208 */ 208 */
209 return FALSE; 209 return FALSE;
210 } 210 }
211 211
212 212
213 void show(QWidget* mw, bool nomax) 213 void show(QWidget* mw, bool nomax)
214 { 214 {
215 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 215 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
216 nomaximize = nomax; 216 nomaximize = nomax;
217 qpe_main_widget = mw; 217 qpe_main_widget = mw;
218 qcopQok = TRUE; 218 qcopQok = TRUE;
219#ifndef QT_NO_COP 219#ifndef QT_NO_COP
220 220
221 sendQCopQ(); 221 sendQCopQ();
222#endif 222#endif
223 223
224 if ( preloaded ) { 224 if ( preloaded ) {
225 if (forceshow) 225 if (forceshow)
226 show_mx(mw, nomax); 226 show_mx(mw, nomax);
227 } 227 }
228 else if ( keep_running ) { 228 else if ( keep_running ) {
229 show_mx(mw, nomax); 229 show_mx(mw, nomax);
230 } 230 }
231 } 231 }
232 232
233 void loadTextCodecs() 233 void loadTextCodecs()
234 { 234 {
235 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 235 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
236 QDir dir( path, "lib*.so" ); 236 QDir dir( path, "lib*.so" );
237 QStringList list; 237 QStringList list;
238 if ( dir. exists ( )) 238 if ( dir. exists ( ))
239 list = dir.entryList(); 239 list = dir.entryList();
240 QStringList::Iterator it; 240 QStringList::Iterator it;
241 for ( it = list.begin(); it != list.end(); ++it ) { 241 for ( it = list.begin(); it != list.end(); ++it ) {
242 TextCodecInterface *iface = 0; 242 TextCodecInterface *iface = 0;
243 QLibrary *lib = new QLibrary( path + "/" + *it ); 243 QLibrary *lib = new QLibrary( path + "/" + *it );
244 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 244 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
245 QValueList<int> mibs = iface->mibEnums(); 245 QValueList<int> mibs = iface->mibEnums();
246 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 246 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
247 (void)iface->createForMib(*i); 247 (void)iface->createForMib(*i);
248 // ### it exists now; need to remember if we can delete it 248 // ### it exists now; need to remember if we can delete it
249 } 249 }
250 } 250 }
251 else { 251 else {
252 lib->unload(); 252 lib->unload();
253 delete lib; 253 delete lib;
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 void loadImageCodecs() 258 void loadImageCodecs()
259 { 259 {
260 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 260 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
261 QDir dir( path, "lib*.so" ); 261 QDir dir( path, "lib*.so" );
262 QStringList list; 262 QStringList list;
263 if ( dir. exists ( )) 263 if ( dir. exists ( ))
264 list = dir.entryList(); 264 list = dir.entryList();
265 QStringList::Iterator it; 265 QStringList::Iterator it;
266 for ( it = list.begin(); it != list.end(); ++it ) { 266 for ( it = list.begin(); it != list.end(); ++it ) {
267 ImageCodecInterface *iface = 0; 267 ImageCodecInterface *iface = 0;
268 QLibrary *lib = new QLibrary( path + "/" + *it ); 268 QLibrary *lib = new QLibrary( path + "/" + *it );
269 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 269 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
270 QStringList formats = iface->keys(); 270 QStringList formats = iface->keys();
271 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 271 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
272 (void)iface->installIOHandler(*i); 272 (void)iface->installIOHandler(*i);
273 // ### it exists now; need to remember if we can delete it 273 // ### it exists now; need to remember if we can delete it
274 } 274 }
275 } 275 }
276 else { 276 else {
277 lib->unload(); 277 lib->unload();
278 delete lib; 278 delete lib;
279 } 279 }
280 } 280 }
281 } 281 }
282}; 282};
283 283
284class ResourceMimeFactory : public QMimeSourceFactory 284class ResourceMimeFactory : public QMimeSourceFactory
285{ 285{
286public: 286public:
287 ResourceMimeFactory() : resImage( 0 ) 287 ResourceMimeFactory() : resImage( 0 )
288 { 288 {
289 setFilePath( Global::helpPath() ); 289 setFilePath( Global::helpPath() );
290 setExtensionType( "html", "text/html;charset=UTF-8" ); 290 setExtensionType( "html", "text/html;charset=UTF-8" );
291 } 291 }
292 ~ResourceMimeFactory() { 292 ~ResourceMimeFactory() {
293 delete resImage; 293 delete resImage;
294 } 294 }
295 295
296 const QMimeSource* data( const QString& abs_name ) const 296 const QMimeSource* data( const QString& abs_name ) const
297 { 297 {
298 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 298 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
299 if ( !r ) { 299 if ( !r ) {
300 int sl = abs_name.length(); 300 int sl = abs_name.length();
301 do { 301 do {
302 sl = abs_name.findRev( '/', sl - 1 ); 302 sl = abs_name.findRev( '/', sl - 1 );
303 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 303 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
304 int dot = name.findRev( '.' ); 304 int dot = name.findRev( '.' );
305 if ( dot >= 0 ) 305 if ( dot >= 0 )
306 name = name.left( dot ); 306 name = name.left( dot );
307 QImage img = Resource::loadImage( name ); 307 QImage img = Resource::loadImage( name );
308 if ( !img.isNull() ) { 308 if ( !img.isNull() ) {
309 delete resImage; 309 delete resImage;
310 resImage = new QImageDrag( img ); 310 resImage = new QImageDrag( img );
311 r = resImage; 311 r = resImage;
312 } 312 }
313 } 313 }
314 while ( !r && sl > 0 ); 314 while ( !r && sl > 0 );
315 } 315 }
316 return r; 316 return r;
317 } 317 }
318private: 318private:
319 mutable QImageDrag *resImage; 319 mutable QImageDrag *resImage;
320}; 320};
321 321
322static int& hack(int& i) 322static int& hack(int& i)
323{ 323{
324#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 324#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
325 // These should be created, but aren't in Qt 2.3.0 325 // These should be created, but aren't in Qt 2.3.0
326 (void)new QUtf8Codec; 326 (void)new QUtf8Codec;
327 (void)new QUtf16Codec; 327 (void)new QUtf16Codec;
328#endif 328#endif
329 return i; 329 return i;
330} 330}
331 331
332static int muted = 0; 332static int muted = 0;
333static int micMuted = 0; 333static int micMuted = 0;
334 334
335static void setVolume( int t = 0, int percent = -1 ) 335static void setVolume( int t = 0, int percent = -1 )
336{ 336{
337 switch ( t ) { 337 switch ( t ) {
338 case 0: { 338 case 0: {
339 Config cfg( "qpe" ); 339 Config cfg( "qpe" );
340 cfg.setGroup( "Volume" ); 340 cfg.setGroup( "Volume" );
341 if ( percent < 0 ) 341 if ( percent < 0 )
342 percent = cfg.readNumEntry( "VolumePercent", 50 ); 342 percent = cfg.readNumEntry( "VolumePercent", 50 );
343 int fd = 0; 343 int fd = 0;
344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
345 int vol = muted ? 0 : percent; 345 int vol = muted ? 0 : percent;
346 // set both channels to same volume 346 // set both channels to same volume
347 vol |= vol << 8; 347 vol |= vol << 8;
348 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 348 ioctl( fd, MIXER_WRITE( 0 ), &vol );
349 ::close( fd ); 349 ::close( fd );
350 } 350 }
351 } 351 }
352 break; 352 break;
353 } 353 }
354} 354}
355 355
356static void setMic( int t = 0, int percent = -1 ) 356static void setMic( int t = 0, int percent = -1 )
357{ 357{
358 switch ( t ) { 358 switch ( t ) {
359 case 0: { 359 case 0: {
360 Config cfg( "qpe" ); 360 Config cfg( "qpe" );
361 cfg.setGroup( "Volume" ); 361 cfg.setGroup( "Volume" );
362 if ( percent < 0 ) 362 if ( percent < 0 )
@@ -401,388 +401,388 @@ static void setTreble( int t = 0, int percent = -1 )
401 case 0: { 401 case 0: {
402 Config cfg( "qpe" ); 402 Config cfg( "qpe" );
403 cfg.setGroup( "Volume" ); 403 cfg.setGroup( "Volume" );
404 if ( percent < 0 ) 404 if ( percent < 0 )
405 percent = cfg.readNumEntry( "TreblePercent", 50 ); 405 percent = cfg.readNumEntry( "TreblePercent", 50 );
406 406
407 int fd = 0; 407 int fd = 0;
408 int treble = percent; 408 int treble = percent;
409 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 409 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
410 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 410 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
411 ::close( fd ); 411 ::close( fd );
412 } 412 }
413 } 413 }
414 break; 414 break;
415 } 415 }
416} 416}
417 417
418 418
419/*! 419/*!
420 \class QPEApplication qpeapplication.h 420 \class QPEApplication qpeapplication.h
421 \brief The QPEApplication class implements various system services 421 \brief The QPEApplication class implements various system services
422 that are available to all Qtopia applications. 422 that are available to all Qtopia applications.
423 423
424 Simply by using QPEApplication instead of QApplication, a standard Qt 424 Simply by using QPEApplication instead of QApplication, a standard Qt
425 application becomes a Qtopia application. It automatically follows 425 application becomes a Qtopia application. It automatically follows
426 style changes, quits and raises, and in the 426 style changes, quits and raises, and in the
427 case of \link docwidget.html document-oriented\endlink applications, 427 case of \link docwidget.html document-oriented\endlink applications,
428 changes the currently displayed document in response to the environment. 428 changes the currently displayed document in response to the environment.
429 429
430 To create a \link docwidget.html document-oriented\endlink 430 To create a \link docwidget.html document-oriented\endlink
431 application use showMainDocumentWidget(); to create a 431 application use showMainDocumentWidget(); to create a
432 non-document-oriented application use showMainWidget(). The 432 non-document-oriented application use showMainWidget(). The
433 keepRunning() function indicates whether the application will 433 keepRunning() function indicates whether the application will
434 continue running after it's processed the last \link qcop.html 434 continue running after it's processed the last \link qcop.html
435 QCop\endlink message. This can be changed using setKeepRunning(). 435 QCop\endlink message. This can be changed using setKeepRunning().
436 436
437 A variety of signals are emitted when certain events occur, for 437 A variety of signals are emitted when certain events occur, for
438 example, timeChanged(), clockChanged(), weekChanged(), 438 example, timeChanged(), clockChanged(), weekChanged(),
439 dateFormatChanged() and volumeChanged(). If the application receives 439 dateFormatChanged() and volumeChanged(). If the application receives
440 a \link qcop.html QCop\endlink message on the application's 440 a \link qcop.html QCop\endlink message on the application's
441 QPE/Application/\e{appname} channel, the appMessage() signal is 441 QPE/Application/\e{appname} channel, the appMessage() signal is
442 emitted. There are also flush() and reload() signals, which 442 emitted. There are also flush() and reload() signals, which
443 are emitted when synching begins and ends respectively - upon these 443 are emitted when synching begins and ends respectively - upon these
444 signals, the application should save and reload any data 444 signals, the application should save and reload any data
445 files that are involved in synching. Most of these signals will initially 445 files that are involved in synching. Most of these signals will initially
446 be received and unfiltered through the appMessage() signal. 446 be received and unfiltered through the appMessage() signal.
447 447
448 This class also provides a set of useful static functions. The 448 This class also provides a set of useful static functions. The
449 qpeDir() and documentDir() functions return the respective paths. 449 qpeDir() and documentDir() functions return the respective paths.
450 The grabKeyboard() and ungrabKeyboard() functions are used to 450 The grabKeyboard() and ungrabKeyboard() functions are used to
451 control whether the application takes control of the device's 451 control whether the application takes control of the device's
452 physical buttons (e.g. application launch keys). The stylus' mode of 452 physical buttons (e.g. application launch keys). The stylus' mode of
453 operation is set with setStylusOperation() and retrieved with 453 operation is set with setStylusOperation() and retrieved with
454 stylusOperation(). There are also setInputMethodHint() and 454 stylusOperation(). There are also setInputMethodHint() and
455 inputMethodHint() functions. 455 inputMethodHint() functions.
456 456
457 \ingroup qtopiaemb 457 \ingroup qtopiaemb
458*/ 458*/
459 459
460/*! 460/*!
461 \fn void QPEApplication::clientMoused() 461 \fn void QPEApplication::clientMoused()
462 462
463 \internal 463 \internal
464*/ 464*/
465 465
466/*! 466/*!
467 \fn void QPEApplication::timeChanged(); 467 \fn void QPEApplication::timeChanged();
468 This signal is emitted when the time changes outside the normal 468 This signal is emitted when the time changes outside the normal
469 passage of time, i.e. if the time is set backwards or forwards. 469 passage of time, i.e. if the time is set backwards or forwards.
470*/ 470*/
471 471
472/*! 472/*!
473 \fn void QPEApplication::clockChanged( bool ampm ); 473 \fn void QPEApplication::clockChanged( bool ampm );
474 474
475 This signal is emitted when the user changes the clock's style. If 475 This signal is emitted when the user changes the clock's style. If
476 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 476 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
477 they want a 24-hour clock. 477 they want a 24-hour clock.
478*/ 478*/
479 479
480/*! 480/*!
481 \fn void QPEApplication::volumeChanged( bool muted ) 481 \fn void QPEApplication::volumeChanged( bool muted )
482 482
483 This signal is emitted whenever the mute state is changed. If \a 483 This signal is emitted whenever the mute state is changed. If \a
484 muted is TRUE, then sound output has been muted. 484 muted is TRUE, then sound output has been muted.
485*/ 485*/
486 486
487/*! 487/*!
488 \fn void QPEApplication::weekChanged( bool startOnMonday ) 488 \fn void QPEApplication::weekChanged( bool startOnMonday )
489 489
490 This signal is emitted if the week start day is changed. If \a 490 This signal is emitted if the week start day is changed. If \a
491 startOnMonday is TRUE then the first day of the week is Monday; if 491 startOnMonday is TRUE then the first day of the week is Monday; if
492 \a startOnMonday is FALSE then the first day of the week is 492 \a startOnMonday is FALSE then the first day of the week is
493 Sunday. 493 Sunday.
494*/ 494*/
495 495
496/*! 496/*!
497 \fn void QPEApplication::dateFormatChanged(DateFormat) 497 \fn void QPEApplication::dateFormatChanged(DateFormat)
498 498
499 This signal is emitted whenever the date format is changed. 499 This signal is emitted whenever the date format is changed.
500*/ 500*/
501 501
502/*! 502/*!
503 \fn void QPEApplication::flush() 503 \fn void QPEApplication::flush()
504 504
505 ### 505 ###
506*/ 506*/
507 507
508/*! 508/*!
509 \fn void QPEApplication::reload() 509 \fn void QPEApplication::reload()
510 510
511*/ 511*/
512 512
513 513
514 514
515void QPEApplication::processQCopFile() 515void QPEApplication::processQCopFile()
516{ 516{
517 QString qcopfn("/tmp/qcop-msg-"); 517 QString qcopfn("/tmp/qcop-msg-");
518 qcopfn += d->appName; // append command name 518 qcopfn += d->appName; // append command name
519 519
520 QFile f(qcopfn); 520 QFile f(qcopfn);
521 if ( f.open(IO_ReadWrite) ) { 521 if ( f.open(IO_ReadWrite) ) {
522#ifndef Q_OS_WIN32 522#ifndef Q_OS_WIN32
523 flock(f.handle(), LOCK_EX); 523 flock(f.handle(), LOCK_EX);
524#endif 524#endif
525 QDataStream ds(&f); 525 QDataStream ds(&f);
526 QCString channel, message; 526 QCString channel, message;
527 QByteArray data; 527 QByteArray data;
528 while(!ds.atEnd()) { 528 while(!ds.atEnd()) {
529 ds >> channel >> message >> data; 529 ds >> channel >> message >> data;
530 d->enqueueQCop(channel,message,data); 530 d->enqueueQCop(channel,message,data);
531 } 531 }
532 ::ftruncate(f.handle(), 0); 532 ::ftruncate(f.handle(), 0);
533#ifndef Q_OS_WIN32 533#ifndef Q_OS_WIN32
534 f.flush(); 534 f.flush();
535 flock(f.handle(), LOCK_UN); 535 flock(f.handle(), LOCK_UN);
536#endif 536#endif
537 } 537 }
538#endif 538#endif
539} 539}
540 540
541 541
542/*! 542/*!
543 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 543 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
544 544
545 This signal is emitted when a message is received on this 545 This signal is emitted when a message is received on this
546 application's QPE/Application/<i>appname</i> \link qcop.html 546 application's QPE/Application/<i>appname</i> \link qcop.html
547 QCop\endlink channel. 547 QCop\endlink channel.
548 548
549 The slot to which you connect this signal uses \a msg and \a data 549 The slot to which you connect this signal uses \a msg and \a data
550 in the following way: 550 in the following way:
551 551
552\code 552\code
553 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 553 void MyWidget::receive( const QCString& msg, const QByteArray& data )
554 { 554 {
555 QDataStream stream( data, IO_ReadOnly ); 555 QDataStream stream( data, IO_ReadOnly );
556 if ( msg == "someMessage(int,int,int)" ) { 556 if ( msg == "someMessage(int,int,int)" ) {
557 int a,b,c; 557 int a,b,c;
558 stream >> a >> b >> c; 558 stream >> a >> b >> c;
559 ... 559 ...
560 } else if ( msg == "otherMessage(QString)" ) { 560 } else if ( msg == "otherMessage(QString)" ) {
561 ... 561 ...
562 } 562 }
563 } 563 }
564\endcode 564\endcode
565 565
566 \sa qcop.html 566 \sa qcop.html
567 Note that messages received here may be processed by qpe application 567 Note that messages received here may be processed by qpe application
568 and emitted as signals, such as flush() and reload(). 568 and emitted as signals, such as flush() and reload().
569*/ 569*/
570 570
571/*! 571/*!
572 Constructs a QPEApplication just as you would construct 572 Constructs a QPEApplication just as you would construct
573 a QApplication, passing \a argc, \a argv, and \a t. 573 a QApplication, passing \a argc, \a argv, and \a t.
574 574
575 For applications, \a t should be the default, GuiClient. Only 575 For applications, \a t should be the default, GuiClient. Only
576 the Qtopia server passes GuiServer. 576 the Qtopia server passes GuiServer.
577*/ 577*/
578QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 578QPEApplication::QPEApplication( int & argc, char **argv, Type t )
579 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 579 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
580{ 580{
581 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 581 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
582 582
583 d = new QPEApplicationData; 583 d = new QPEApplicationData;
584 d->loadTextCodecs(); 584 d->loadTextCodecs();
585 d->loadImageCodecs(); 585 d->loadImageCodecs();
586 int dw = desktop() ->width(); 586 int dw = desktop() ->width();
587 587
588 if ( dw < 200 ) { 588 if ( dw < 200 ) {
589 setFont( QFont( "vera", 8 ) ); 589 setFont( QFont( "vera", 8 ) );
590 AppLnk::setSmallIconSize( 10 ); 590 AppLnk::setSmallIconSize( 10 );
591 AppLnk::setBigIconSize( 28 ); 591 AppLnk::setBigIconSize( 28 );
592 } 592 }
593#ifndef QT_QWS_SIMPAD 593#ifndef OPIE_HIGH_RES_SMALL_PHY
594 else if ( dw > 600 ) { 594 else if ( dw > 600 ) {
595 setFont( QFont( "vera", 16 ) ); 595 setFont( QFont( "vera", 16 ) );
596 AppLnk::setSmallIconSize( 24 ); 596 AppLnk::setSmallIconSize( 24 );
597 AppLnk::setBigIconSize( 48 ); 597 AppLnk::setBigIconSize( 48 );
598 } 598 }
599#endif 599#endif
600 else if ( dw > 200 ) { 600 else if ( dw > 200 ) {
601 setFont( QFont( "vera", 10 ) ); 601 setFont( QFont( "vera", 10 ) );
602 AppLnk::setSmallIconSize( 14 ); 602 AppLnk::setSmallIconSize( 14 );
603 AppLnk::setBigIconSize( 32 ); 603 AppLnk::setBigIconSize( 32 );
604 } 604 }
605 605
606 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 606 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
607 607
608 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 608 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
609 609
610 610
611 sysChannel = new QCopChannel( "QPE/System", this ); 611 sysChannel = new QCopChannel( "QPE/System", this );
612 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 612 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
613 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 613 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
614 614
615/* COde now in initapp */ 615/* COde now in initapp */
616#if 0 616#if 0
617#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 617#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
618 618
619 QString qcopfn( "/tmp/qcop-msg-" ); 619 QString qcopfn( "/tmp/qcop-msg-" );
620 qcopfn += QString( argv[ 0 ] ); // append command name 620 qcopfn += QString( argv[ 0 ] ); // append command name
621 621
622 QFile f( qcopfn ); 622 QFile f( qcopfn );
623 if ( f.open( IO_ReadOnly ) ) { 623 if ( f.open( IO_ReadOnly ) ) {
624 flock( f.handle(), LOCK_EX ); 624 flock( f.handle(), LOCK_EX );
625 } 625 }
626 626
627 627
628 628
629 QCString channel = QCString( argv[ 0 ] ); 629 QCString channel = QCString( argv[ 0 ] );
630 channel.replace( QRegExp( ".*/" ), "" ); 630 channel.replace( QRegExp( ".*/" ), "" );
631 d->appName = channel; 631 d->appName = channel;
632 channel = "QPE/Application/" + channel; 632 channel = "QPE/Application/" + channel;
633 pidChannel = new QCopChannel( channel, this ); 633 pidChannel = new QCopChannel( channel, this );
634 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 634 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
635 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 635 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
636 636
637 if ( f.isOpen() ) { 637 if ( f.isOpen() ) {
638 d->keep_running = FALSE; 638 d->keep_running = FALSE;
639 QDataStream ds( &f ); 639 QDataStream ds( &f );
640 QCString channel, message; 640 QCString channel, message;
641 QByteArray data; 641 QByteArray data;
642 while ( !ds.atEnd() ) { 642 while ( !ds.atEnd() ) {
643 ds >> channel >> message >> data; 643 ds >> channel >> message >> data;
644 d->enqueueQCop( channel, message, data ); 644 d->enqueueQCop( channel, message, data );
645 } 645 }
646 646
647 flock( f.handle(), LOCK_UN ); 647 flock( f.handle(), LOCK_UN );
648 f.close(); 648 f.close();
649 f.remove(); 649 f.remove();
650 } 650 }
651 651
652 for ( int a = 0; a < argc; a++ ) { 652 for ( int a = 0; a < argc; a++ ) {
653 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 653 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
654 argv[ a ] = argv[ a + 1 ]; 654 argv[ a ] = argv[ a + 1 ];
655 a++; 655 a++;
656 d->preloaded = TRUE; 656 d->preloaded = TRUE;
657 argc -= 1; 657 argc -= 1;
658 } 658 }
659 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 659 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
660 argv[ a ] = argv[ a + 1 ]; 660 argv[ a ] = argv[ a + 1 ];
661 a++; 661 a++;
662 d->preloaded = TRUE; 662 d->preloaded = TRUE;
663 d->forceshow = TRUE; 663 d->forceshow = TRUE;
664 argc -= 1; 664 argc -= 1;
665 } 665 }
666 } 666 }
667 667
668 /* overide stored arguments */ 668 /* overide stored arguments */
669 setArgs( argc, argv ); 669 setArgs( argc, argv );
670 670
671#endif 671#endif
672#else 672#else
673 initApp( argc, argv ); 673 initApp( argc, argv );
674#endif 674#endif
675 // qwsSetDecoration( new QPEDecoration() ); 675 // qwsSetDecoration( new QPEDecoration() );
676 676
677#ifndef QT_NO_TRANSLATION 677#ifndef QT_NO_TRANSLATION
678 678
679 d->langs = Global::languageList(); 679 d->langs = Global::languageList();
680 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 680 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
681 QString lang = *it; 681 QString lang = *it;
682 682
683 installTranslation( lang + "/libopie.qm"); 683 installTranslation( lang + "/libopie.qm");
684 installTranslation( lang + "/libqpe.qm" ); 684 installTranslation( lang + "/libqpe.qm" );
685 installTranslation( lang + "/" + d->appName + ".qm" ); 685 installTranslation( lang + "/" + d->appName + ".qm" );
686 686
687 687
688 //###language/font hack; should look it up somewhere 688 //###language/font hack; should look it up somewhere
689#ifdef QWS 689#ifdef QWS
690 690
691 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 691 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
692 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 692 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
693 setFont( fn ); 693 setFont( fn );
694 } 694 }
695#endif 695#endif
696 } 696 }
697#endif 697#endif
698 698
699 applyStyle(); 699 applyStyle();
700 700
701 if ( type() == GuiServer ) { 701 if ( type() == GuiServer ) {
702 setVolume(); 702 setVolume();
703 } 703 }
704 704
705 installEventFilter( this ); 705 installEventFilter( this );
706 706
707 QPEMenuToolFocusManager::initialize(); 707 QPEMenuToolFocusManager::initialize();
708 708
709#ifdef QT_NO_QWS_CURSOR 709#ifdef QT_NO_QWS_CURSOR
710 // if we have no cursor, probably don't want tooltips 710 // if we have no cursor, probably don't want tooltips
711 QToolTip::setEnabled( FALSE ); 711 QToolTip::setEnabled( FALSE );
712#endif 712#endif
713} 713}
714 714
715 715
716#ifdef QTOPIA_INTERNAL_INITAPP 716#ifdef QTOPIA_INTERNAL_INITAPP
717void QPEApplication::initApp( int argc, char **argv ) 717void QPEApplication::initApp( int argc, char **argv )
718{ 718{
719 bool initial = pidChannel; // was set to 0 in the initializer 719 bool initial = pidChannel; // was set to 0 in the initializer
720 delete pidChannel; 720 delete pidChannel;
721 d->keep_running = TRUE; 721 d->keep_running = TRUE;
722 d->preloaded = FALSE; 722 d->preloaded = FALSE;
723 d->forceshow = FALSE; 723 d->forceshow = FALSE;
724 724
725 QCString channel = QCString(argv[0]); 725 QCString channel = QCString(argv[0]);
726 726
727 channel.replace(QRegExp(".*/"),""); 727 channel.replace(QRegExp(".*/"),"");
728 d->appName = channel; 728 d->appName = channel;
729 729
730 #if QT_VERSION > 235 730 #if QT_VERSION > 235
731 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 731 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
732 #endif 732 #endif
733 733
734 channel = "QPE/Application/" + channel; 734 channel = "QPE/Application/" + channel;
735 pidChannel = new QCopChannel( channel, this); 735 pidChannel = new QCopChannel( channel, this);
736 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 736 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
737 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 737 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
738 738
739 if (!initial) { 739 if (!initial) {
740 processQCopFile(); 740 processQCopFile();
741 d->keep_running = d->qcopq.isEmpty(); 741 d->keep_running = d->qcopq.isEmpty();
742 } 742 }
743 743
744 for (int a=0; a<argc; a++) { 744 for (int a=0; a<argc; a++) {
745 if ( qstrcmp(argv[a],"-preload")==0 ) { 745 if ( qstrcmp(argv[a],"-preload")==0 ) {
746 argv[a] = argv[a+1]; 746 argv[a] = argv[a+1];
747 a++; 747 a++;
748 d->preloaded = TRUE; 748 d->preloaded = TRUE;
749 argc-=1; 749 argc-=1;
750 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 750 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
751 argv[a] = argv[a+1]; 751 argv[a] = argv[a+1];
752 a++; 752 a++;
753 d->preloaded = TRUE; 753 d->preloaded = TRUE;
754 d->forceshow = TRUE; 754 d->forceshow = TRUE;
755 argc-=1; 755 argc-=1;
756 } 756 }
757 } 757 }
758 758
759 /* overide stored arguments */ 759 /* overide stored arguments */
760 setArgs(argc, argv); 760 setArgs(argc, argv);
761 761
762 /* install translation here */ 762 /* install translation here */
763 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 763 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
764 installTranslation( (*it) + "/" + d->appName + ".qm" ); 764 installTranslation( (*it) + "/" + d->appName + ".qm" );
765} 765}
766#endif 766#endif
767 767
768 768
769static QPtrDict<void>* inputMethodDict = 0; 769static QPtrDict<void>* inputMethodDict = 0;
770static void createInputMethodDict() 770static void createInputMethodDict()
771{ 771{
772 if ( !inputMethodDict ) 772 if ( !inputMethodDict )
773 inputMethodDict = new QPtrDict<void>; 773 inputMethodDict = new QPtrDict<void>;
774} 774}
775 775
776/*! 776/*!
777 Returns the currently set hint to the system as to whether 777 Returns the currently set hint to the system as to whether
778 widget \a w has any use for text input methods. 778 widget \a w has any use for text input methods.
779 779
780 780
781 \sa setInputMethodHint() InputMethodHint 781 \sa setInputMethodHint() InputMethodHint
782*/ 782*/
783QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 783QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
784{ 784{
785 if ( inputMethodDict && w ) 785 if ( inputMethodDict && w )
786 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 786 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
787 return Normal; 787 return Normal;
788} 788}
@@ -1819,256 +1819,256 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1819 if ( d->rightpressed && d->presswidget ) { 1819 if ( d->rightpressed && d->presswidget ) {
1820 // Right released 1820 // Right released
1821 postEvent( d->presswidget, 1821 postEvent( d->presswidget,
1822 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1822 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1823 RightButton, LeftButton + RightButton ) ); 1823 RightButton, LeftButton + RightButton ) );
1824 // Left released, off-widget 1824 // Left released, off-widget
1825 postEvent( d->presswidget, 1825 postEvent( d->presswidget,
1826 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 1826 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
1827 LeftButton, LeftButton ) ); 1827 LeftButton, LeftButton ) );
1828 postEvent( d->presswidget, 1828 postEvent( d->presswidget,
1829 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 1829 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
1830 LeftButton, LeftButton ) ); 1830 LeftButton, LeftButton ) );
1831 d->rightpressed = FALSE; 1831 d->rightpressed = FALSE;
1832 return TRUE; // don't send the real Left release 1832 return TRUE; // don't send the real Left release
1833 } 1833 }
1834 } 1834 }
1835 break; 1835 break;
1836 default: 1836 default:
1837 break; 1837 break;
1838 } 1838 }
1839 break; 1839 break;
1840 default: 1840 default:
1841 ; 1841 ;
1842 } 1842 }
1843 } 1843 }
1844 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1844 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1845 QKeyEvent *ke = (QKeyEvent *)e; 1845 QKeyEvent *ke = (QKeyEvent *)e;
1846 if ( ke->key() == Key_Enter ) { 1846 if ( ke->key() == Key_Enter ) {
1847 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1847 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1848 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1848 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1849 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1849 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1850 return TRUE; 1850 return TRUE;
1851 } 1851 }
1852 } 1852 }
1853 } 1853 }
1854 return FALSE; 1854 return FALSE;
1855} 1855}
1856 1856
1857/*! 1857/*!
1858 \reimp 1858 \reimp
1859*/ 1859*/
1860void QPEApplication::timerEvent( QTimerEvent *e ) 1860void QPEApplication::timerEvent( QTimerEvent *e )
1861{ 1861{
1862 if ( e->timerId() == d->presstimer && d->presswidget ) { 1862 if ( e->timerId() == d->presstimer && d->presswidget ) {
1863 // Right pressed 1863 // Right pressed
1864 postEvent( d->presswidget, 1864 postEvent( d->presswidget,
1865 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1865 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1866 RightButton, LeftButton ) ); 1866 RightButton, LeftButton ) );
1867 killTimer( d->presstimer ); 1867 killTimer( d->presstimer );
1868 d->presstimer = 0; 1868 d->presstimer = 0;
1869 d->rightpressed = TRUE; 1869 d->rightpressed = TRUE;
1870 } 1870 }
1871} 1871}
1872 1872
1873void QPEApplication::removeSenderFromStylusDict() 1873void QPEApplication::removeSenderFromStylusDict()
1874{ 1874{
1875 stylusDict->remove 1875 stylusDict->remove
1876 ( ( void* ) sender() ); 1876 ( ( void* ) sender() );
1877 if ( d->presswidget == sender() ) 1877 if ( d->presswidget == sender() )
1878 d->presswidget = 0; 1878 d->presswidget = 0;
1879} 1879}
1880 1880
1881/*! 1881/*!
1882 \internal 1882 \internal
1883*/ 1883*/
1884bool QPEApplication::keyboardGrabbed() const 1884bool QPEApplication::keyboardGrabbed() const
1885{ 1885{
1886 return d->kbgrabbed; 1886 return d->kbgrabbed;
1887} 1887}
1888 1888
1889 1889
1890/*! 1890/*!
1891 Reverses the effect of grabKeyboard(). This is called automatically 1891 Reverses the effect of grabKeyboard(). This is called automatically
1892 on program exit. 1892 on program exit.
1893*/ 1893*/
1894void QPEApplication::ungrabKeyboard() 1894void QPEApplication::ungrabKeyboard()
1895{ 1895{
1896 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 1896 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
1897} 1897}
1898 1898
1899/*! 1899/*!
1900 Grabs the physical keyboard keys, e.g. the application's launching 1900 Grabs the physical keyboard keys, e.g. the application's launching
1901 keys. Instead of launching applications when these keys are pressed 1901 keys. Instead of launching applications when these keys are pressed
1902 the signals emitted are sent to this application instead. Some games 1902 the signals emitted are sent to this application instead. Some games
1903 programs take over the launch keys in this way to make interaction 1903 programs take over the launch keys in this way to make interaction
1904 easier. 1904 easier.
1905 1905
1906 \sa ungrabKeyboard() 1906 \sa ungrabKeyboard()
1907*/ 1907*/
1908void QPEApplication::grabKeyboard() 1908void QPEApplication::grabKeyboard()
1909{ 1909{
1910 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 1910 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
1911} 1911}
1912 1912
1913/*! 1913/*!
1914 \reimp 1914 \reimp
1915*/ 1915*/
1916int QPEApplication::exec() 1916int QPEApplication::exec()
1917{ 1917{
1918 d->qcopQok = true; 1918 d->qcopQok = true;
1919#ifndef QT_NO_COP 1919#ifndef QT_NO_COP
1920 d->sendQCopQ(); 1920 d->sendQCopQ();
1921 if ( !d->keep_running ) 1921 if ( !d->keep_running )
1922 processEvents(); // we may have received QCop messages in the meantime. 1922 processEvents(); // we may have received QCop messages in the meantime.
1923#endif 1923#endif
1924 1924
1925 if ( d->keep_running ) 1925 if ( d->keep_running )
1926 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1926 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1927 return QApplication::exec(); 1927 return QApplication::exec();
1928 1928
1929#ifndef QT_NO_COP 1929#ifndef QT_NO_COP
1930 1930
1931 { 1931 {
1932 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1932 QCopEnvelope e( "QPE/System", "closing(QString)" );
1933 e << d->appName; 1933 e << d->appName;
1934 } 1934 }
1935#endif 1935#endif
1936 processEvents(); 1936 processEvents();
1937 return 0; 1937 return 0;
1938} 1938}
1939 1939
1940/*! 1940/*!
1941 \internal 1941 \internal
1942 External request for application to quit. Quits if possible without 1942 External request for application to quit. Quits if possible without
1943 loosing state. 1943 loosing state.
1944*/ 1944*/
1945void QPEApplication::tryQuit() 1945void QPEApplication::tryQuit()
1946{ 1946{
1947 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1947 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1948 return ; // Inside modal loop or konsole. Too hard to save state. 1948 return ; // Inside modal loop or konsole. Too hard to save state.
1949#ifndef QT_NO_COP 1949#ifndef QT_NO_COP
1950 1950
1951 { 1951 {
1952 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1952 QCopEnvelope e( "QPE/System", "closing(QString)" );
1953 e << d->appName; 1953 e << d->appName;
1954 } 1954 }
1955#endif 1955#endif
1956 processEvents(); 1956 processEvents();
1957 1957
1958 quit(); 1958 quit();
1959} 1959}
1960 1960
1961/*! 1961/*!
1962 \internal 1962 \internal
1963*/ 1963*/
1964void QPEApplication::installTranslation( const QString& baseName ) { 1964void QPEApplication::installTranslation( const QString& baseName ) {
1965 QTranslator* trans = new QTranslator(this); 1965 QTranslator* trans = new QTranslator(this);
1966 QString tfn = qpeDir() + "/i18n/"+baseName; 1966 QString tfn = qpeDir() + "/i18n/"+baseName;
1967 if ( trans->load( tfn ) ) 1967 if ( trans->load( tfn ) )
1968 installTranslator( trans ); 1968 installTranslator( trans );
1969 else 1969 else
1970 delete trans; 1970 delete trans;
1971} 1971}
1972 1972
1973/*! 1973/*!
1974 \internal 1974 \internal
1975 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1975 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1976 hiding the window. If not it means quitting the application. 1976 hiding the window. If not it means quitting the application.
1977 As this is user initiated we don't need to check state. 1977 As this is user initiated we don't need to check state.
1978*/ 1978*/
1979void QPEApplication::hideOrQuit() 1979void QPEApplication::hideOrQuit()
1980{ 1980{
1981 processEvents(); 1981 processEvents();
1982 1982
1983 // If we are a preloaded application we don't actually quit, so emit 1983 // If we are a preloaded application we don't actually quit, so emit
1984 // a System message indicating we're quasi-closing. 1984 // a System message indicating we're quasi-closing.
1985 if ( d->preloaded && d->qpe_main_widget ) 1985 if ( d->preloaded && d->qpe_main_widget )
1986#ifndef QT_NO_COP 1986#ifndef QT_NO_COP
1987 1987
1988 { 1988 {
1989 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1989 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1990 e << d->appName; 1990 e << d->appName;
1991 d->qpe_main_widget->hide(); 1991 d->qpe_main_widget->hide();
1992 } 1992 }
1993#endif 1993#endif
1994 else 1994 else
1995 quit(); 1995 quit();
1996} 1996}
1997 1997
1998#if (__GNUC__ > 2 ) 1998#if (__GNUC__ > 2 )
1999extern "C" void __cxa_pure_virtual(); 1999extern "C" void __cxa_pure_virtual();
2000 2000
2001void __cxa_pure_virtual() 2001void __cxa_pure_virtual()
2002{ 2002{
2003 fprintf( stderr, "Pure virtual called\n"); 2003 fprintf( stderr, "Pure virtual called\n");
2004 abort(); 2004 abort();
2005 2005
2006} 2006}
2007 2007
2008#endif 2008#endif
2009 2009
2010 2010
2011#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) 2011#if defined(OPIE_NEW_MALLOC)
2012 2012
2013// The libraries with the skiff package (and possibly others) have 2013// The libraries with the skiff package (and possibly others) have
2014// completely useless implementations of builtin new and delete that 2014// completely useless implementations of builtin new and delete that
2015// use about 50% of your CPU. Here we revert to the simple libc 2015// use about 50% of your CPU. Here we revert to the simple libc
2016// functions. 2016// functions.
2017 2017
2018void* operator new[]( size_t size ) 2018void* operator new[]( size_t size )
2019{ 2019{
2020 return malloc( size ); 2020 return malloc( size );
2021} 2021}
2022 2022
2023void* operator new( size_t size ) 2023void* operator new( size_t size )
2024{ 2024{
2025 return malloc( size ); 2025 return malloc( size );
2026} 2026}
2027 2027
2028void operator delete[]( void* p ) 2028void operator delete[]( void* p )
2029{ 2029{
2030 free( p ); 2030 free( p );
2031} 2031}
2032 2032
2033void operator delete[]( void* p, size_t /*size*/ ) 2033void operator delete[]( void* p, size_t /*size*/ )
2034{ 2034{
2035 free( p ); 2035 free( p );
2036} 2036}
2037 2037
2038 2038
2039void operator delete( void* p ) 2039void operator delete( void* p )
2040{ 2040{
2041 free( p ); 2041 free( p );
2042} 2042}
2043 2043
2044void operator delete( void* p, size_t /*size*/ ) 2044void operator delete( void* p, size_t /*size*/ )
2045{ 2045{
2046 free( p ); 2046 free( p );
2047} 2047}
2048 2048
2049#endif 2049#endif
2050 2050
2051#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2051#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2052#include <qwidgetlist.h> 2052#include <qwidgetlist.h>
2053#ifdef QWS 2053#ifdef QWS
2054#include <qgfx_qws.h> 2054#include <qgfx_qws.h>
2055extern QRect qt_maxWindowRect; 2055extern QRect qt_maxWindowRect;
2056void qt_setMaxWindowRect(const QRect& r ) 2056void qt_setMaxWindowRect(const QRect& r )
2057{ 2057{
2058 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2058 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2059 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2059 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2060 // Re-resize any maximized windows 2060 // Re-resize any maximized windows
2061 QWidgetList* l = QApplication::topLevelWidgets(); 2061 QWidgetList* l = QApplication::topLevelWidgets();
2062 if ( l ) { 2062 if ( l ) {
2063 QWidget * w = l->first(); 2063 QWidget * w = l->first();
2064 while ( w ) { 2064 while ( w ) {
2065 if ( w->isVisible() && w->isMaximized() ) { 2065 if ( w->isVisible() && w->isMaximized() ) {
2066 w->showMaximized(); 2066 w->showMaximized();
2067 } 2067 }
2068 w = l->next(); 2068 w = l->next();
2069 } 2069 }
2070 delete l; 2070 delete l;
2071 } 2071 }
2072} 2072}
2073#endif 2073#endif
2074#endif 2074#endif
diff --git a/library/storage.cpp b/library/storage.cpp
index 1ce43bc..dc5cc22 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,218 +1,216 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> 2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) Lorn Potter <llornkcor@handhelds.org> 3** Copyright (C) Lorn Potter <llornkcor@handhelds.org>
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Opie Environment. 6** This file is part of Opie Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#include <qpe/storage.h> 23#include <qpe/storage.h>
24#if defined(QT_QWS_SL5XXX)
25#include <qpe/custom.h> 24#include <qpe/custom.h>
26#endif
27 25
28#include <qfile.h> 26#include <qfile.h>
29#include <qtimer.h> 27#include <qtimer.h>
30#include <qcopchannel_qws.h> 28#include <qcopchannel_qws.h>
31 29
32#include <stdio.h> 30#include <stdio.h>
33 31
34#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 32#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
35#include <sys/vfs.h> 33#include <sys/vfs.h>
36#include <mntent.h> 34#include <mntent.h>
37#endif 35#endif
38 36
39#include <qstringlist.h> 37#include <qstringlist.h>
40 38
41#include <sys/vfs.h> 39#include <sys/vfs.h>
42#include <mntent.h> 40#include <mntent.h>
43 41
44 42
45static bool isCF(const QString& m) 43static bool isCF(const QString& m)
46{ 44{
47 FILE* f = fopen("/var/run/stab", "r"); 45 FILE* f = fopen("/var/run/stab", "r");
48 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 46 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
49 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 47 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
50 if ( f ) { 48 if ( f ) {
51 char line[1024]; 49 char line[1024];
52 char devtype[80]; 50 char devtype[80];
53 char devname[80]; 51 char devname[80];
54 while ( fgets( line, 1024, f ) ) { 52 while ( fgets( line, 1024, f ) ) {
55 // 0 ide ide-cs 0 hda 3 0 53 // 0 ide ide-cs 0 hda 3 0
56 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 54 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
57 { 55 {
58 if ( QString(devtype) == "ide" && m.find(devname)>0 ) { 56 if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
59 fclose(f); 57 fclose(f);
60 return TRUE; 58 return TRUE;
61 } 59 }
62 } 60 }
63 } 61 }
64 fclose(f); 62 fclose(f);
65 } 63 }
66 return FALSE; 64 return FALSE;
67} 65}
68 66
69/*! \class StorageInfo storage.h 67/*! \class StorageInfo storage.h
70 \brief The StorageInfo class describes the disks mounted on the file system. 68 \brief The StorageInfo class describes the disks mounted on the file system.
71 69
72 This class provides access to the mount information for the Linux 70 This class provides access to the mount information for the Linux
73 filesystem. Each mount point is represented by the FileSystem class. 71 filesystem. Each mount point is represented by the FileSystem class.
74 To ensure this class has the most up to date size information, call 72 To ensure this class has the most up to date size information, call
75 the update() method. Note that this will automatically be signaled 73 the update() method. Note that this will automatically be signaled
76 by the operating system when a disk has been mounted or unmounted. 74 by the operating system when a disk has been mounted or unmounted.
77 75
78 \ingroup qtopiaemb 76 \ingroup qtopiaemb
79*/ 77*/
80 78
81/*! Constructor that determines the current mount points of the filesystem. 79/*! Constructor that determines the current mount points of the filesystem.
82 The standard \a parent parameters is passed on to QObject. 80 The standard \a parent parameters is passed on to QObject.
83 */ 81 */
84StorageInfo::StorageInfo( QObject *parent ) 82StorageInfo::StorageInfo( QObject *parent )
85 : QObject( parent ) 83 : QObject( parent )
86{ 84{
87 mFileSystems.setAutoDelete( TRUE ); 85 mFileSystems.setAutoDelete( TRUE );
88 channel = new QCopChannel( "QPE/Card", this ); 86 channel = new QCopChannel( "QPE/Card", this );
89 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 87 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
90 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 88 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
91 update(); 89 update();
92} 90}
93 91
94/*! Returns the longest matching FileSystem that starts with the 92/*! Returns the longest matching FileSystem that starts with the
95 same prefix as \a filename as its mount point. 93 same prefix as \a filename as its mount point.
96*/ 94*/
97const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 95const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
98{ 96{
99 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 97 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
100 if ( filename.startsWith( (*i)->path() ) ) 98 if ( filename.startsWith( (*i)->path() ) )
101 return (*i); 99 return (*i);
102 } 100 }
103 return 0; 101 return 0;
104} 102}
105 103
106 104
107void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 105void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
108{ 106{
109 if ( msg == "mtabChanged()" ) 107 if ( msg == "mtabChanged()" )
110 update(); 108 update();
111} 109}
112 110
113 111
114/*! Updates the mount and free space available information for each mount 112/*! Updates the mount and free space available information for each mount
115 point. This method is automatically called when a disk is mounted or 113 point. This method is automatically called when a disk is mounted or
116 unmounted. 114 unmounted.
117*/ 115*/
118// cause of the lack of a d pointer we need 116// cause of the lack of a d pointer we need
119// to store informations in a config file :( 117// to store informations in a config file :(
120void StorageInfo::update() 118void StorageInfo::update()
121{ 119{
122 //qDebug("StorageInfo::updating"); 120 //qDebug("StorageInfo::updating");
123#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 121#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
124 struct mntent *me; 122 struct mntent *me;
125 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 123 FILE *mntfp = setmntent( "/etc/mtab", "r" );
126 124
127 QStringList curdisks; 125 QStringList curdisks;
128 QStringList curopts; 126 QStringList curopts;
129 QStringList curfs; 127 QStringList curfs;
130 bool rebuild = FALSE; 128 bool rebuild = FALSE;
131 int n=0; 129 int n=0;
132 if ( mntfp ) { 130 if ( mntfp ) {
133 while ( (me = getmntent( mntfp )) != 0 ) { 131 while ( (me = getmntent( mntfp )) != 0 ) {
134 QString fs = me->mnt_fsname; 132 QString fs = me->mnt_fsname;
135 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 133 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
136 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" 134 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
137 || fs.left( 14 ) == "/dev/mmc/part1" 135 || fs.left( 14 ) == "/dev/mmc/part1"
138 || fs.left(5)=="tmpfs" || fs.left(9)=="/dev/root" ) 136 || fs.left(5)=="tmpfs" || fs.left(9)=="/dev/root" )
139 { 137 {
140 n++; 138 n++;
141 curdisks.append(fs); 139 curdisks.append(fs);
142 curopts.append( me->mnt_opts ); 140 curopts.append( me->mnt_opts );
143 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); 141 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
144 curfs.append( me->mnt_dir ); 142 curfs.append( me->mnt_dir );
145 bool found = FALSE; 143 bool found = FALSE;
146 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 144 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
147 if ( (*i)->disk() == fs ) { 145 if ( (*i)->disk() == fs ) {
148 found = TRUE; 146 found = TRUE;
149 break; 147 break;
150 } 148 }
151 } 149 }
152 if ( !found ) 150 if ( !found )
153 rebuild = TRUE; 151 rebuild = TRUE;
154 } 152 }
155 } 153 }
156 endmntent( mntfp ); 154 endmntent( mntfp );
157 } 155 }
158 if ( rebuild || n != (int)mFileSystems.count() ) { 156 if ( rebuild || n != (int)mFileSystems.count() ) {
159 mFileSystems.clear(); 157 mFileSystems.clear();
160 QStringList::ConstIterator it=curdisks.begin(); 158 QStringList::ConstIterator it=curdisks.begin();
161 QStringList::ConstIterator fsit=curfs.begin(); 159 QStringList::ConstIterator fsit=curfs.begin();
162 QStringList::ConstIterator optsIt=curopts.begin(); 160 QStringList::ConstIterator optsIt=curopts.begin();
163 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { 161 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) {
164 QString opts = *optsIt; 162 QString opts = *optsIt;
165 163
166 QString disk = *it; 164 QString disk = *it;
167 QString humanname; 165 QString humanname;
168 bool removable = FALSE; 166 bool removable = FALSE;
169 if ( isCF(disk) ) { 167 if ( isCF(disk) ) {
170 humanname = tr("CF Card"); 168 humanname = tr("CF Card");
171 removable = TRUE; 169 removable = TRUE;
172 } else if ( disk == "/dev/hda1" ) { 170 } else if ( disk == "/dev/hda1" ) {
173 humanname = tr("Hard Disk"); 171 humanname = tr("Hard Disk");
174 } else if ( disk.left(9) == "/dev/mmcd" ) { 172 } else if ( disk.left(9) == "/dev/mmcd" ) {
175 humanname = tr("SD Card"); 173 humanname = tr("SD Card");
176 removable = TRUE; 174 removable = TRUE;
177 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { 175 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) {
178 humanname = tr("MMC Card"); 176 humanname = tr("MMC Card");
179 removable = TRUE; 177 removable = TRUE;
180 } else if ( disk.left(7) == "/dev/hd" ) 178 } else if ( disk.left(7) == "/dev/hd" )
181 humanname = tr("Hard Disk") + " " + disk; 179 humanname = tr("Hard Disk") + " " + disk;
182 else if ( disk.left(7) == "/dev/sd" ) 180 else if ( disk.left(7) == "/dev/sd" )
183 humanname = tr("SCSI Hard Disk") + " " + disk; 181 humanname = tr("SCSI Hard Disk") + " " + disk;
184 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs 182 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
185 humanname = tr("Internal Memory"); 183 humanname = tr("Internal Memory");
186 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 184 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
187 humanname = tr("Internal Storage"); 185 humanname = tr("Internal Storage");
188 else if ( disk.left(14) == "/dev/mtdblock/" ) 186 else if ( disk.left(14) == "/dev/mtdblock/" )
189 humanname = tr("Internal Storage") + " " + disk; 187 humanname = tr("Internal Storage") + " " + disk;
190 else if ( disk.left(13) == "/dev/mtdblock" ) 188 else if ( disk.left(13) == "/dev/mtdblock" )
191 humanname = tr("Internal Storage") + " " + disk; 189 humanname = tr("Internal Storage") + " " + disk;
192 else if ( disk.left(9) == "/dev/root" ) 190 else if ( disk.left(9) == "/dev/root" )
193 humanname = tr("Internal Storage") + " " + disk; 191 humanname = tr("Internal Storage") + " " + disk;
194 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs 192 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
195 humanname = tr("Internal Memory"); 193 humanname = tr("Internal Memory");
196 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); 194 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
197 mFileSystems.append( fs ); 195 mFileSystems.append( fs );
198 } 196 }
199 emit disksChanged(); 197 emit disksChanged();
200 } else { 198 } else {
201 // just update them 199 // just update them
202 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 200 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
203 i.current()->update(); 201 i.current()->update();
204 } 202 }
205#endif 203#endif
206} 204}
207 205
208bool deviceTab( const char *device) { 206bool deviceTab( const char *device) {
209 QString name = device; 207 QString name = device;
210 bool hasDevice=false; 208 bool hasDevice=false;
211 struct mntent *me; 209 struct mntent *me;
212 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 210 FILE *mntfp = setmntent( "/etc/mtab", "r" );
213 if ( mntfp ) { 211 if ( mntfp ) {
214 while ( (me = getmntent( mntfp )) != 0 ) { 212 while ( (me = getmntent( mntfp )) != 0 ) {
215 QString deviceName = me->mnt_fsname; 213 QString deviceName = me->mnt_fsname;
216// qDebug(deviceName); 214// qDebug(deviceName);
217 if( deviceName.left(name.length()) == name) { 215 if( deviceName.left(name.length()) == name) {
218 hasDevice = true; 216 hasDevice = true;