author | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 12:18:17 (UTC) |
commit | 9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (patch) (unidiff) | |
tree | 53927c6a19c69d54bb3d0e092ac57180bcb60222 | |
parent | ed70ec4945c7816ec6e899207ec8b99e20e10da5 (diff) | |
download | opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.zip opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.gz opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.bz2 |
added support for DEVFS
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 10 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 8 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 5 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 16 |
5 files changed, 40 insertions, 3 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index e747a19..07ef15c 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,665 +1,669 @@ | |||
1 | /************************************************************************************ | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> | 12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> |
13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> | 13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> |
14 | 14 | ||
15 | /* OPIE */ | 15 | /* OPIE */ |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | using namespace Opie::Core; | 17 | using namespace Opie::Core; |
18 | 18 | ||
19 | extern "C" { | 19 | extern "C" { |
20 | #include "adpcm.h" | 20 | #include "adpcm.h" |
21 | } | 21 | } |
22 | 22 | ||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <sys/ioctl.h> | 26 | #include <sys/ioctl.h> |
27 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
28 | 28 | ||
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | 30 | ||
31 | typedef struct _waveheader { | 31 | typedef struct _waveheader { |
32 | u_long main_chunk; /* 'RIFF' */ | 32 | u_long main_chunk; /* 'RIFF' */ |
33 | u_long length; /* filelen */ | 33 | u_long length; /* filelen */ |
34 | u_long chunk_type; /* 'WAVE' */ | 34 | u_long chunk_type; /* 'WAVE' */ |
35 | u_long sub_chunk; /* 'fmt ' */ | 35 | u_long sub_chunk; /* 'fmt ' */ |
36 | u_long sc_len; /* length of sub_chunk, =16 | 36 | u_long sc_len; /* length of sub_chunk, =16 |
37 | (chunckSize) format len */ | 37 | (chunckSize) format len */ |
38 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 38 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
39 | 39 | ||
40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
45 | 45 | ||
46 | u_long data_chunk; /* 'data' */ | 46 | u_long data_chunk; /* 'data' */ |
47 | 47 | ||
48 | u_long data_length;/* samplecount */ | 48 | u_long data_length;/* samplecount */ |
49 | } WaveHeader; | 49 | } WaveHeader; |
50 | 50 | ||
51 | #define RIFF 0x46464952 | 51 | #define RIFF 0x46464952 |
52 | #define WAVE 0x45564157 | 52 | #define WAVE 0x45564157 |
53 | #define FMT 0x20746D66 | 53 | #define FMT 0x20746D66 |
54 | #define DATA 0x61746164 | 54 | #define DATA 0x61746164 |
55 | #define PCM_CODE 1 | 55 | #define PCM_CODE 1 |
56 | #define WAVE_MONO 1 | 56 | #define WAVE_MONO 1 |
57 | #define WAVE_STEREO 2 | 57 | #define WAVE_STEREO 2 |
58 | 58 | ||
59 | struct adpcm_state encoder_state; | 59 | struct adpcm_state encoder_state; |
60 | //struct adpcm_state decoder_state; | 60 | //struct adpcm_state decoder_state; |
61 | 61 | ||
62 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 62 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
63 | #define WAVE_FORMAT_PCM (0x0001) | 63 | #define WAVE_FORMAT_PCM (0x0001) |
64 | 64 | ||
65 | 65 | ||
66 | #include "vmemo.h" | 66 | #include "vmemo.h" |
67 | 67 | ||
68 | #include <opie2/otaskbarapplet.h> | 68 | #include <opie2/otaskbarapplet.h> |
69 | #include <qpe/qpeapplication.h> | 69 | #include <qpe/qpeapplication.h> |
70 | #include <qpe/config.h> | 70 | #include <qpe/config.h> |
71 | 71 | ||
72 | #include <qpainter.h> | 72 | #include <qpainter.h> |
73 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
74 | 74 | ||
75 | int seq = 0; | 75 | int seq = 0; |
76 | 76 | ||
77 | /* XPM */ | 77 | /* XPM */ |
78 | static char * vmemo_xpm[] = { | 78 | static char * vmemo_xpm[] = { |
79 | "16 16 102 2", | 79 | "16 16 102 2", |
80 | " c None", | 80 | " c None", |
81 | ". c #60636A", | 81 | ". c #60636A", |
82 | "+ c #6E6E72", | 82 | "+ c #6E6E72", |
83 | "@ c #68696E", | 83 | "@ c #68696E", |
84 | "# c #4D525C", | 84 | "# c #4D525C", |
85 | "$ c #6B6C70", | 85 | "$ c #6B6C70", |
86 | "% c #E3E3E8", | 86 | "% c #E3E3E8", |
87 | "& c #EEEEF2", | 87 | "& c #EEEEF2", |
88 | "* c #EAEAEF", | 88 | "* c #EAEAEF", |
89 | "= c #CACAD0", | 89 | "= c #CACAD0", |
90 | "- c #474A51", | 90 | "- c #474A51", |
91 | "; c #171819", | 91 | "; c #171819", |
92 | "> c #9B9B9F", | 92 | "> c #9B9B9F", |
93 | ", c #EBEBF0", | 93 | ", c #EBEBF0", |
94 | "' c #F4F4F7", | 94 | "' c #F4F4F7", |
95 | ") c #F1F1F5", | 95 | ") c #F1F1F5", |
96 | "! c #DEDEE4", | 96 | "! c #DEDEE4", |
97 | "~ c #57575C", | 97 | "~ c #57575C", |
98 | "{ c #010101", | 98 | "{ c #010101", |
99 | "] c #A2A2A6", | 99 | "] c #A2A2A6", |
100 | "^ c #747477", | 100 | "^ c #747477", |
101 | "/ c #B5B5B8", | 101 | "/ c #B5B5B8", |
102 | "( c #AEAEB2", | 102 | "( c #AEAEB2", |
103 | "_ c #69696D", | 103 | "_ c #69696D", |
104 | ": c #525256", | 104 | ": c #525256", |
105 | "< c #181C24", | 105 | "< c #181C24", |
106 | "[ c #97979B", | 106 | "[ c #97979B", |
107 | "} c #A7A7AC", | 107 | "} c #A7A7AC", |
108 | "| c #B0B0B4", | 108 | "| c #B0B0B4", |
109 | "1 c #C8C8D1", | 109 | "1 c #C8C8D1", |
110 | "2 c #75757B", | 110 | "2 c #75757B", |
111 | "3 c #46464A", | 111 | "3 c #46464A", |
112 | "4 c #494A4F", | 112 | "4 c #494A4F", |
113 | "5 c #323234", | 113 | "5 c #323234", |
114 | "6 c #909095", | 114 | "6 c #909095", |
115 | "7 c #39393B", | 115 | "7 c #39393B", |
116 | "8 c #757578", | 116 | "8 c #757578", |
117 | "9 c #87878E", | 117 | "9 c #87878E", |
118 | "0 c #222224", | 118 | "0 c #222224", |
119 | "a c #414144", | 119 | "a c #414144", |
120 | "b c #6A6A6E", | 120 | "b c #6A6A6E", |
121 | "c c #020C16", | 121 | "c c #020C16", |
122 | "d c #6B6B6F", | 122 | "d c #6B6B6F", |
123 | "e c #68686D", | 123 | "e c #68686D", |
124 | "f c #5B5B60", | 124 | "f c #5B5B60", |
125 | "g c #8A8A8F", | 125 | "g c #8A8A8F", |
126 | "h c #6B6B6E", | 126 | "h c #6B6B6E", |
127 | "i c #ADADB2", | 127 | "i c #ADADB2", |
128 | "j c #828289", | 128 | "j c #828289", |
129 | "k c #3E3E41", | 129 | "k c #3E3E41", |
130 | "l c #CFCFD7", | 130 | "l c #CFCFD7", |
131 | "m c #4C4C50", | 131 | "m c #4C4C50", |
132 | "n c #000000", | 132 | "n c #000000", |
133 | "o c #66666A", | 133 | "o c #66666A", |
134 | "p c #505054", | 134 | "p c #505054", |
135 | "q c #838388", | 135 | "q c #838388", |
136 | "r c #A1A1A7", | 136 | "r c #A1A1A7", |
137 | "s c #A9A9AE", | 137 | "s c #A9A9AE", |
138 | "t c #A8A8B0", | 138 | "t c #A8A8B0", |
139 | "u c #5E5E63", | 139 | "u c #5E5E63", |
140 | "v c #3A3A3E", | 140 | "v c #3A3A3E", |
141 | "w c #BDBDC6", | 141 | "w c #BDBDC6", |
142 | "x c #59595E", | 142 | "x c #59595E", |
143 | "y c #76767C", | 143 | "y c #76767C", |
144 | "z c #373738", | 144 | "z c #373738", |
145 | "A c #717174", | 145 | "A c #717174", |
146 | "B c #727278", | 146 | "B c #727278", |
147 | "C c #1C1C1E", | 147 | "C c #1C1C1E", |
148 | "D c #3C3C3F", | 148 | "D c #3C3C3F", |
149 | "E c #ADADB6", | 149 | "E c #ADADB6", |
150 | "F c #54555A", | 150 | "F c #54555A", |
151 | "G c #8B8C94", | 151 | "G c #8B8C94", |
152 | "H c #5A5A5F", | 152 | "H c #5A5A5F", |
153 | "I c #BBBBC3", | 153 | "I c #BBBBC3", |
154 | "J c #C4C4CB", | 154 | "J c #C4C4CB", |
155 | "K c #909098", | 155 | "K c #909098", |
156 | "L c #737379", | 156 | "L c #737379", |
157 | "M c #343437", | 157 | "M c #343437", |
158 | "N c #8F8F98", | 158 | "N c #8F8F98", |
159 | "O c #000407", | 159 | "O c #000407", |
160 | "P c #2D3137", | 160 | "P c #2D3137", |
161 | "Q c #B0B1BC", | 161 | "Q c #B0B1BC", |
162 | "R c #3B3C40", | 162 | "R c #3B3C40", |
163 | "S c #6E6E74", | 163 | "S c #6E6E74", |
164 | "T c #95959C", | 164 | "T c #95959C", |
165 | "U c #74747A", | 165 | "U c #74747A", |
166 | "V c #1D1D1E", | 166 | "V c #1D1D1E", |
167 | "W c #91929A", | 167 | "W c #91929A", |
168 | "X c #42444A", | 168 | "X c #42444A", |
169 | "Y c #22282E", | 169 | "Y c #22282E", |
170 | "Z c #B0B2BC", | 170 | "Z c #B0B2BC", |
171 | "` c #898A90", | 171 | "` c #898A90", |
172 | " . c #65656A", | 172 | " . c #65656A", |
173 | ".. c #999AA2", | 173 | ".. c #999AA2", |
174 | "+. c #52535A", | 174 | "+. c #52535A", |
175 | "@. c #151B21", | 175 | "@. c #151B21", |
176 | "#. c #515257", | 176 | "#. c #515257", |
177 | "$. c #B5B5BE", | 177 | "$. c #B5B5BE", |
178 | "%. c #616167", | 178 | "%. c #616167", |
179 | "&. c #1A1D22", | 179 | "&. c #1A1D22", |
180 | "*. c #000713", | 180 | "*. c #000713", |
181 | "=. c #1F1F21", | 181 | "=. c #1F1F21", |
182 | " ", | 182 | " ", |
183 | " . + @ # ", | 183 | " . + @ # ", |
184 | " $ % & * = - ", | 184 | " $ % & * = - ", |
185 | " ; > , ' ) ! ~ ", | 185 | " ; > , ' ) ! ~ ", |
186 | " { ] ^ / ( _ : ", | 186 | " { ] ^ / ( _ : ", |
187 | " < [ } | 1 2 3 ", | 187 | " < [ } | 1 2 3 ", |
188 | " 4 5 6 7 8 9 0 a b c ", | 188 | " 4 5 6 7 8 9 0 a b c ", |
189 | " d e f g h i j 3 k l m n ", | 189 | " d e f g h i j 3 k l m n ", |
190 | " o p q r s t u v w n ", | 190 | " o p q r s t u v w n ", |
191 | " o x y z A B C D E n ", | 191 | " o x y z A B C D E n ", |
192 | " F G H I J K L M N O ", | 192 | " F G H I J K L M N O ", |
193 | " P Q R S T U V W X ", | 193 | " P Q R S T U V W X ", |
194 | " Y Z ` b ...+. ", | 194 | " Y Z ` b ...+. ", |
195 | " @.#.$.%.&. ", | 195 | " @.#.$.%.&. ", |
196 | " *.B =. ", | 196 | " *.B =. ", |
197 | " n n n n n n n n n "}; | 197 | " n n n n n n n n n "}; |
198 | 198 | ||
199 | 199 | ||
200 | using namespace Opie::Ui; | 200 | using namespace Opie::Ui; |
201 | VMemo::VMemo( QWidget *parent, const char *_name ) | 201 | VMemo::VMemo( QWidget *parent, const char *_name ) |
202 | : QWidget( parent, _name ) { | 202 | : QWidget( parent, _name ) { |
203 | setFixedHeight( 18 ); | 203 | setFixedHeight( 18 ); |
204 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
205 | 205 | ||
206 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
208 | 208 | ||
209 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
210 | vmCfg.setGroup("Defaults"); | 210 | vmCfg.setGroup("Defaults"); |
211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
213 | 213 | ||
214 | odebug << "toggleKey " << toggleKey << "" << oendl; | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
215 | 215 | ||
216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
217 | // systemZaurus=TRUE; | 217 | // systemZaurus=TRUE; |
218 | // else | 218 | // else |
219 | systemZaurus = FALSE; | 219 | systemZaurus = FALSE; |
220 | 220 | ||
221 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 221 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
224 | 224 | ||
225 | if( toggleKey != -1 ) { | 225 | if( toggleKey != -1 ) { |
226 | odebug << "Register key " << toggleKey << "" << oendl; | 226 | odebug << "Register key " << toggleKey << "" << oendl; |
227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
228 | // e << 4096; // Key_Escape | 228 | // e << 4096; // Key_Escape |
229 | // e << Key_F5; //4148 | 229 | // e << Key_F5; //4148 |
230 | e << toggleKey; | 230 | e << toggleKey; |
231 | e << QString("QPE/VMemo"); | 231 | e << QString("QPE/VMemo"); |
232 | e << QString("toggleRecord()"); | 232 | e << QString("toggleRecord()"); |
233 | } | 233 | } |
234 | if(toggleKey == 1) | 234 | if(toggleKey == 1) |
235 | usingIcon = TRUE; | 235 | usingIcon = TRUE; |
236 | else | 236 | else |
237 | usingIcon = FALSE; | 237 | usingIcon = FALSE; |
238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) | 238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | if (!usingIcon) | 239 | if (!usingIcon) |
240 | hide(); | 240 | hide(); |
241 | recording = FALSE; | 241 | recording = FALSE; |
242 | // } | 242 | // } |
243 | } | 243 | } |
244 | 244 | ||
245 | VMemo::~VMemo() { | 245 | VMemo::~VMemo() { |
246 | } | 246 | } |
247 | 247 | ||
248 | int VMemo::position() | 248 | int VMemo::position() |
249 | { | 249 | { |
250 | return 6; | 250 | return 6; |
251 | } | 251 | } |
252 | 252 | ||
253 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 253 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
254 | odebug << "Vmemo receive" << oendl; | 254 | odebug << "Vmemo receive" << oendl; |
255 | QDataStream stream( data, IO_ReadOnly ); | 255 | QDataStream stream( data, IO_ReadOnly ); |
256 | 256 | ||
257 | if (msg == "toggleRecord()") { | 257 | if (msg == "toggleRecord()") { |
258 | if (recording) { | 258 | if (recording) { |
259 | fromToggle = TRUE; | 259 | fromToggle = TRUE; |
260 | stopRecording(); | 260 | stopRecording(); |
261 | } else { | 261 | } else { |
262 | fromToggle = TRUE; | 262 | fromToggle = TRUE; |
263 | startRecording(); | 263 | startRecording(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void VMemo::paintEvent( QPaintEvent* ) { | 268 | void VMemo::paintEvent( QPaintEvent* ) { |
269 | QPainter p(this); | 269 | QPainter p(this); |
270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { | 273 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { |
274 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 274 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
275 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 275 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
276 | 276 | ||
277 | // if (!systemZaurus && me != NULL) | 277 | // if (!systemZaurus && me != NULL) |
278 | // return; | 278 | // return; |
279 | // } | 279 | // } |
280 | 280 | ||
281 | if(!recording) | 281 | if(!recording) |
282 | startRecording(); | 282 | startRecording(); |
283 | else | 283 | else |
284 | stopRecording(); | 284 | stopRecording(); |
285 | } | 285 | } |
286 | 286 | ||
287 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 287 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
288 | } | 288 | } |
289 | 289 | ||
290 | bool VMemo::startRecording() { | 290 | bool VMemo::startRecording() { |
291 | Config config( "Vmemo" ); | 291 | Config config( "Vmemo" ); |
292 | config.setGroup( "System" ); | 292 | config.setGroup( "System" ); |
293 | 293 | ||
294 | useAlerts = config.readBoolEntry("Alert",1); | 294 | useAlerts = config.readBoolEntry("Alert",1); |
295 | if(useAlerts) { | 295 | if(useAlerts) { |
296 | 296 | ||
297 | msgLabel = new QLabel( 0, "alertLabel" ); | 297 | msgLabel = new QLabel( 0, "alertLabel" ); |
298 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 298 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
299 | msgLabel->show(); | 299 | msgLabel->show(); |
300 | } | 300 | } |
301 | 301 | ||
302 | odebug << "Start recording engines" << oendl; | 302 | odebug << "Start recording engines" << oendl; |
303 | recording = TRUE; | 303 | recording = TRUE; |
304 | 304 | ||
305 | if (openDSP() == -1) { | 305 | if (openDSP() == -1) { |
306 | recording = FALSE; | 306 | recording = FALSE; |
307 | return FALSE; | 307 | return FALSE; |
308 | } | 308 | } |
309 | 309 | ||
310 | config.setGroup("Defaults"); | 310 | config.setGroup("Defaults"); |
311 | 311 | ||
312 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 312 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
313 | date.replace(QRegExp("'"),""); | 313 | date.replace(QRegExp("'"),""); |
314 | date.replace(QRegExp(" "),"_"); | 314 | date.replace(QRegExp(" "),"_"); |
315 | date.replace(QRegExp(":"),"-"); | 315 | date.replace(QRegExp(":"),"-"); |
316 | date.replace(QRegExp(","),""); | 316 | date.replace(QRegExp(","),""); |
317 | 317 | ||
318 | QString fName; | 318 | QString fName; |
319 | config.setGroup( "System" ); | 319 | config.setGroup( "System" ); |
320 | fName = QPEApplication::documentDir() ; | 320 | fName = QPEApplication::documentDir() ; |
321 | fileName = config.readEntry("RecLocation", fName); | 321 | fileName = config.readEntry("RecLocation", fName); |
322 | 322 | ||
323 | int s; | 323 | int s; |
324 | s=fileName.find(':'); | 324 | s=fileName.find(':'); |
325 | if(s) | 325 | if(s) |
326 | fileName=fileName.right(fileName.length()-s-2); | 326 | fileName=fileName.right(fileName.length()-s-2); |
327 | odebug << "pathname will be "+fileName << oendl; | 327 | odebug << "pathname will be "+fileName << oendl; |
328 | 328 | ||
329 | if( fileName.left(1).find('/') == -1) | 329 | if( fileName.left(1).find('/') == -1) |
330 | fileName="/"+fileName; | 330 | fileName="/"+fileName; |
331 | if( fileName.right(1).find('/') == -1) | 331 | if( fileName.right(1).find('/') == -1) |
332 | fileName+="/"; | 332 | fileName+="/"; |
333 | fName = "vm_"+ date + ".wav"; | 333 | fName = "vm_"+ date + ".wav"; |
334 | 334 | ||
335 | fileName+=fName; | 335 | fileName+=fName; |
336 | odebug << "filename is " + fileName << oendl; | 336 | odebug << "filename is " + fileName << oendl; |
337 | // open tmp file here | 337 | // open tmp file here |
338 | char *pointer; | 338 | char *pointer; |
339 | pointer=tmpnam(NULL); | 339 | pointer=tmpnam(NULL); |
340 | odebug << "Opening tmp file " << pointer << "" << oendl; | 340 | odebug << "Opening tmp file " << pointer << "" << oendl; |
341 | 341 | ||
342 | if(openWAV(pointer ) == -1) { | 342 | if(openWAV(pointer ) == -1) { |
343 | 343 | ||
344 | QString err("Could not open the temp file\n"); | 344 | QString err("Could not open the temp file\n"); |
345 | err += fileName; | 345 | err += fileName; |
346 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 346 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
347 | ::close(dsp); | 347 | ::close(dsp); |
348 | return FALSE; | 348 | return FALSE; |
349 | } | 349 | } |
350 | if( record() ) { | 350 | if( record() ) { |
351 | 351 | ||
352 | QString cmd; | 352 | QString cmd; |
353 | if( fileName.find(".wav",0,TRUE) == -1) | 353 | if( fileName.find(".wav",0,TRUE) == -1) |
354 | fileName += ".wav"; | 354 | fileName += ".wav"; |
355 | 355 | ||
356 | cmd.sprintf("mv %s "+fileName, pointer); | 356 | cmd.sprintf("mv %s "+fileName, pointer); |
357 | // move tmp file to regular file here | 357 | // move tmp file to regular file here |
358 | 358 | ||
359 | system(cmd.latin1()); | 359 | system(cmd.latin1()); |
360 | 360 | ||
361 | QArray<int> cats(1); | 361 | QArray<int> cats(1); |
362 | cats[0] = config.readNumEntry("Category", 0); | 362 | cats[0] = config.readNumEntry("Category", 0); |
363 | 363 | ||
364 | QString dlName("vm_"); | 364 | QString dlName("vm_"); |
365 | dlName += date; | 365 | dlName += date; |
366 | DocLnk l; | 366 | DocLnk l; |
367 | l.setFile(fileName); | 367 | l.setFile(fileName); |
368 | l.setName(dlName); | 368 | l.setName(dlName); |
369 | l.setType("audio/x-wav"); | 369 | l.setType("audio/x-wav"); |
370 | l.setCategories(cats); | 370 | l.setCategories(cats); |
371 | l.writeLink(); | 371 | l.writeLink(); |
372 | return TRUE; | 372 | return TRUE; |
373 | } else | 373 | } else |
374 | return FALSE; | 374 | return FALSE; |
375 | 375 | ||
376 | } | 376 | } |
377 | 377 | ||
378 | void VMemo::stopRecording() { | 378 | void VMemo::stopRecording() { |
379 | // show(); | 379 | // show(); |
380 | odebug << "Stopped recording" << oendl; | 380 | odebug << "Stopped recording" << oendl; |
381 | recording = FALSE; | 381 | recording = FALSE; |
382 | if(useAlerts) { | 382 | if(useAlerts) { |
383 | msgLabel->close(); | 383 | msgLabel->close(); |
384 | msgLabel=0; | 384 | msgLabel=0; |
385 | delete msgLabel; | 385 | delete msgLabel; |
386 | } | 386 | } |
387 | t_timer->stop(); | 387 | t_timer->stop(); |
388 | Config cfg("Vmemo"); | 388 | Config cfg("Vmemo"); |
389 | cfg.setGroup("Defaults"); | 389 | cfg.setGroup("Defaults"); |
390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) | 390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) |
391 | // hide(); | 391 | // hide(); |
392 | } | 392 | } |
393 | 393 | ||
394 | int VMemo::openDSP() { | 394 | int VMemo::openDSP() { |
395 | Config cfg("Vmemo"); | 395 | Config cfg("Vmemo"); |
396 | cfg.setGroup("Record"); | 396 | cfg.setGroup("Record"); |
397 | 397 | ||
398 | speed = cfg.readNumEntry("SampleRate", 22050); | 398 | speed = cfg.readNumEntry("SampleRate", 22050); |
399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
401 | format = AFMT_S16_LE; | 401 | format = AFMT_S16_LE; |
402 | resolution = 16; | 402 | resolution = 16; |
403 | } else { | 403 | } else { |
404 | format = AFMT_U8; | 404 | format = AFMT_U8; |
405 | resolution = 8; | 405 | resolution = 8; |
406 | } | 406 | } |
407 | 407 | ||
408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; | 408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
409 | 409 | ||
410 | if(systemZaurus) { | 410 | if(systemZaurus) { |
411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
412 | channels=1; //zaurus has one input channel | 412 | channels=1; //zaurus has one input channel |
413 | } else { | 413 | } else { |
414 | #ifdef QT_QWS_DEVFS | ||
415 | dsp = open("/dev/sound/dsp", O_RDONLY); | ||
416 | #else | ||
414 | dsp = open("/dev/dsp", O_RDONLY); | 417 | dsp = open("/dev/dsp", O_RDONLY); |
418 | #endif | ||
415 | } | 419 | } |
416 | 420 | ||
417 | if(dsp == -1) { | 421 | if (dsp == -1) { |
418 | msgLabel->close(); | 422 | msgLabel->close(); |
419 | msgLabel=0; | 423 | msgLabel=0; |
420 | delete msgLabel; | 424 | delete msgLabel; |
421 | 425 | ||
422 | perror("open(\"/dev/dsp\")"); | 426 | perror("open(\"/dev/dsp\")"); |
423 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 427 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
424 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 428 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
425 | return -1; | 429 | return -1; |
426 | } | 430 | } |
427 | 431 | ||
428 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 432 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
429 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 433 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
430 | return -1; | 434 | return -1; |
431 | } | 435 | } |
432 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 436 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
433 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 437 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
434 | return -1; | 438 | return -1; |
435 | } | 439 | } |
436 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 440 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
437 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 441 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
438 | return -1; | 442 | return -1; |
439 | } | 443 | } |
440 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 444 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
441 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 445 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
442 | return -1; | 446 | return -1; |
443 | } | 447 | } |
444 | 448 | ||
445 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 449 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
446 | 450 | ||
447 | return 1; | 451 | return 1; |
448 | } | 452 | } |
449 | 453 | ||
450 | int VMemo::openWAV(const char *filename) { | 454 | int VMemo::openWAV(const char *filename) { |
451 | track.setName(filename); | 455 | track.setName(filename); |
452 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 456 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
453 | errorMsg=filename; | 457 | errorMsg=filename; |
454 | return -1; | 458 | return -1; |
455 | } | 459 | } |
456 | 460 | ||
457 | wav=track.handle(); | 461 | wav=track.handle(); |
458 | Config vmCfg("Vmemo"); | 462 | Config vmCfg("Vmemo"); |
459 | vmCfg.setGroup("Defaults"); | 463 | vmCfg.setGroup("Defaults"); |
460 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 464 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
461 | 465 | ||
462 | WaveHeader wh; | 466 | WaveHeader wh; |
463 | 467 | ||
464 | wh.main_chunk = RIFF; | 468 | wh.main_chunk = RIFF; |
465 | wh.length=0; | 469 | wh.length=0; |
466 | wh.chunk_type = WAVE; | 470 | wh.chunk_type = WAVE; |
467 | wh.sub_chunk = FMT; | 471 | wh.sub_chunk = FMT; |
468 | wh.sc_len = 16; | 472 | wh.sc_len = 16; |
469 | if(useADPCM) | 473 | if(useADPCM) |
470 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 474 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
471 | else | 475 | else |
472 | wh.format = PCM_CODE; | 476 | wh.format = PCM_CODE; |
473 | wh.modus = channels; | 477 | wh.modus = channels; |
474 | wh.sample_fq = speed; | 478 | wh.sample_fq = speed; |
475 | wh.byte_p_sec = speed * channels * resolution/8; | 479 | wh.byte_p_sec = speed * channels * resolution/8; |
476 | wh.byte_p_spl = channels * (resolution / 8); | 480 | wh.byte_p_spl = channels * (resolution / 8); |
477 | wh.bit_p_spl = resolution; | 481 | wh.bit_p_spl = resolution; |
478 | wh.data_chunk = DATA; | 482 | wh.data_chunk = DATA; |
479 | wh.data_length= 0; | 483 | wh.data_length= 0; |
480 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " | 484 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " |
481 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; | 485 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; |
482 | write (wav, &wh, sizeof(WaveHeader)); | 486 | write (wav, &wh, sizeof(WaveHeader)); |
483 | 487 | ||
484 | return 1; | 488 | return 1; |
485 | } | 489 | } |
486 | 490 | ||
487 | bool VMemo::record() { | 491 | bool VMemo::record() { |
488 | length = 0; | 492 | length = 0; |
489 | int bytesWritten = 0; | 493 | int bytesWritten = 0; |
490 | int result = 0; | 494 | int result = 0; |
491 | int value = 0; | 495 | int value = 0; |
492 | 496 | ||
493 | QString msg; | 497 | QString msg; |
494 | msg.sprintf("Recording format %d", format); | 498 | msg.sprintf("Recording format %d", format); |
495 | odebug << msg << oendl; | 499 | odebug << msg << oendl; |
496 | 500 | ||
497 | Config config("Vmemo"); | 501 | Config config("Vmemo"); |
498 | config.setGroup("Record"); | 502 | config.setGroup("Record"); |
499 | int sRate = config.readNumEntry("SizeLimit", 30); | 503 | int sRate = config.readNumEntry("SizeLimit", 30); |
500 | odebug << "VMEMO rate" << sRate << oendl; | 504 | odebug << "VMEMO rate" << sRate << oendl; |
501 | 505 | ||
502 | if(sRate > 0) { | 506 | if(sRate > 0) { |
503 | t_timer->start( sRate * 1000+1000, TRUE); | 507 | t_timer->start( sRate * 1000+1000, TRUE); |
504 | } | 508 | } |
505 | 509 | ||
506 | msg.sprintf("Recording format other"); | 510 | msg.sprintf("Recording format other"); |
507 | odebug << msg << oendl; | 511 | odebug << msg << oendl; |
508 | 512 | ||
509 | config.setGroup("Defaults"); | 513 | config.setGroup("Defaults"); |
510 | useADPCM = config.readBoolEntry("use_ADPCM", 0); | 514 | useADPCM = config.readBoolEntry("use_ADPCM", 0); |
511 | 515 | ||
512 | int bufsize = config.readNumEntry("BufferSize",1024); | 516 | int bufsize = config.readNumEntry("BufferSize",1024); |
513 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; | 517 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; |
514 | char abuf[bufsize / 2]; | 518 | char abuf[bufsize / 2]; |
515 | short sbuf[bufsize]; | 519 | short sbuf[bufsize]; |
516 | odebug << "ready to record"<< oendl; | 520 | odebug << "ready to record"<< oendl; |
517 | if(useADPCM) { | 521 | if(useADPCM) { |
518 | odebug << "usr ADPCM" << oendl; | 522 | odebug << "usr ADPCM" << oendl; |
519 | 523 | ||
520 | while(recording) { | 524 | while(recording) { |
521 | result = ::read(dsp, sbuf, bufsize); // adpcm read | 525 | result = ::read(dsp, sbuf, bufsize); // adpcm read |
522 | if( result <= 0) { | 526 | if( result <= 0) { |
523 | perror("recording error "); | 527 | perror("recording error "); |
524 | QMessageBox::message(tr("Note"),tr("error recording")); | 528 | QMessageBox::message(tr("Note"),tr("error recording")); |
525 | recording = FALSE; | 529 | recording = FALSE; |
526 | break; | 530 | break; |
527 | return FALSE; | 531 | return FALSE; |
528 | } | 532 | } |
529 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 533 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
530 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write | 534 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write |
531 | length += bytesWritten; | 535 | length += bytesWritten; |
532 | 536 | ||
533 | if(length < 0) { | 537 | if(length < 0) { |
534 | recording = false; | 538 | recording = false; |
535 | perror("dev/dsp's is a lookin' messy"); | 539 | perror("dev/dsp's is a lookin' messy"); |
536 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 540 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
537 | break; | 541 | break; |
538 | return FALSE; | 542 | return FALSE; |
539 | } | 543 | } |
540 | printf("%d\r", length); | 544 | printf("%d\r", length); |
541 | fflush(stdout); | 545 | fflush(stdout); |
542 | qApp->processEvents(); | 546 | qApp->processEvents(); |
543 | } | 547 | } |
544 | } else { | 548 | } else { |
545 | odebug << "use regular wav" << oendl; | 549 | odebug << "use regular wav" << oendl; |
546 | while(recording) { | 550 | while(recording) { |
547 | result = ::read(dsp, sound, bufsize); // read | 551 | result = ::read(dsp, sound, bufsize); // read |
548 | if( result <= 0) { | 552 | if( result <= 0) { |
549 | perror("recording error "); | 553 | perror("recording error "); |
550 | QMessageBox::message(tr("Note"),tr("error recording")); | 554 | QMessageBox::message(tr("Note"),tr("error recording")); |
551 | recording = FALSE; | 555 | recording = FALSE; |
552 | break; | 556 | break; |
553 | return FALSE; | 557 | return FALSE; |
554 | } | 558 | } |
555 | 559 | ||
556 | bytesWritten = ::write(wav, sound, result); // write | 560 | bytesWritten = ::write(wav, sound, result); // write |
557 | length += bytesWritten; | 561 | length += bytesWritten; |
558 | 562 | ||
559 | if(length < 0) { | 563 | if(length < 0) { |
560 | recording = false; | 564 | recording = false; |
561 | perror("dev/dsp's is a lookin' messy"); | 565 | perror("dev/dsp's is a lookin' messy"); |
562 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 566 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
563 | break; | 567 | break; |
564 | return FALSE; | 568 | return FALSE; |
565 | } | 569 | } |
566 | // printf("%d\r", length); | 570 | // printf("%d\r", length); |
567 | // fflush(stdout); | 571 | // fflush(stdout); |
568 | qApp->processEvents(); | 572 | qApp->processEvents(); |
569 | } | 573 | } |
570 | // odebug << "result is " << result << oendl; | 574 | // odebug << "result is " << result << oendl; |
571 | } | 575 | } |
572 | odebug << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl; | 576 | odebug << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl; |
573 | 577 | ||
574 | value = length + 36; | 578 | value = length + 36; |
575 | 579 | ||
576 | lseek(wav, 4, SEEK_SET); | 580 | lseek(wav, 4, SEEK_SET); |
577 | write(wav, &value, 4); | 581 | write(wav, &value, 4); |
578 | lseek(wav, 40, SEEK_SET); | 582 | lseek(wav, 40, SEEK_SET); |
579 | 583 | ||
580 | write(wav, &length, 4); | 584 | write(wav, &length, 4); |
581 | 585 | ||
582 | track.close(); | 586 | track.close(); |
583 | odebug << "Track closed" << oendl; | 587 | odebug << "Track closed" << oendl; |
584 | 588 | ||
585 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 589 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
586 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 590 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
587 | 591 | ||
588 | ::close(dsp); | 592 | ::close(dsp); |
589 | 593 | ||
590 | Config cfgO("OpieRec"); | 594 | Config cfgO("OpieRec"); |
591 | cfgO.setGroup("Sounds"); | 595 | cfgO.setGroup("Sounds"); |
592 | 596 | ||
593 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); | 597 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); |
594 | 598 | ||
595 | QString currentFileName = fileName; | 599 | QString currentFileName = fileName; |
596 | QString currentFile = "vm_"+ date; | 600 | QString currentFile = "vm_"+ date; |
597 | 601 | ||
598 | float numberOfRecordedSeconds = (float) length / (float)speed * (float)2; | 602 | float numberOfRecordedSeconds = (float) length / (float)speed * (float)2; |
599 | 603 | ||
600 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); | 604 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); |
601 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); | 605 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); |
602 | cfgO.writeEntry( currentFile, currentFileName); | 606 | cfgO.writeEntry( currentFile, currentFileName); |
603 | 607 | ||
604 | QString time; | 608 | QString time; |
605 | time.sprintf("%.2f", numberOfRecordedSeconds); | 609 | time.sprintf("%.2f", numberOfRecordedSeconds); |
606 | cfgO.writeEntry( currentFileName, time ); | 610 | cfgO.writeEntry( currentFileName, time ); |
607 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; | 611 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
608 | 612 | ||
609 | cfgO.write(); | 613 | cfgO.write(); |
610 | 614 | ||
611 | odebug << "done recording "+fileName << oendl; | 615 | odebug << "done recording "+fileName << oendl; |
612 | 616 | ||
613 | Config cfg("qpe"); | 617 | Config cfg("qpe"); |
614 | cfg.setGroup("Volume"); | 618 | cfg.setGroup("Volume"); |
615 | QString foo = cfg.readEntry("Mute","TRUE"); | 619 | QString foo = cfg.readEntry("Mute","TRUE"); |
616 | if(foo.find("TRUE",0,TRUE) != -1) | 620 | if(foo.find("TRUE",0,TRUE) != -1) |
617 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 621 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
618 | return TRUE; | 622 | return TRUE; |
619 | } | 623 | } |
620 | 624 | ||
621 | int VMemo::setToggleButton(int tog) { | 625 | int VMemo::setToggleButton(int tog) { |
622 | 626 | ||
623 | for( int i=0; i < 10;i++) { | 627 | for( int i=0; i < 10;i++) { |
624 | switch (tog) { | 628 | switch (tog) { |
625 | case 0: | 629 | case 0: |
626 | return -1; | 630 | return -1; |
627 | break; | 631 | break; |
628 | case 1: | 632 | case 1: |
629 | return 0; | 633 | return 0; |
630 | break; | 634 | break; |
631 | case 2: | 635 | case 2: |
632 | return Key_F24; //was Escape | 636 | return Key_F24; //was Escape |
633 | break; | 637 | break; |
634 | case 3: | 638 | case 3: |
635 | return Key_Space; | 639 | return Key_Space; |
636 | break; | 640 | break; |
637 | case 4: | 641 | case 4: |
638 | return Key_F12; | 642 | return Key_F12; |
639 | break; | 643 | break; |
640 | case 5: | 644 | case 5: |
641 | return Key_F9; | 645 | return Key_F9; |
642 | break; | 646 | break; |
643 | case 6: | 647 | case 6: |
644 | return Key_F10; | 648 | return Key_F10; |
645 | break; | 649 | break; |
646 | case 7: | 650 | case 7: |
647 | return Key_F11; | 651 | return Key_F11; |
648 | break; | 652 | break; |
649 | case 8: | 653 | case 8: |
650 | return Key_F13; | 654 | return Key_F13; |
651 | break; | 655 | break; |
652 | }; | 656 | }; |
653 | } | 657 | } |
654 | return -1; | 658 | return -1; |
655 | } | 659 | } |
656 | 660 | ||
657 | void VMemo::timerBreak() { | 661 | void VMemo::timerBreak() { |
658 | //stop | 662 | //stop |
659 | stopRecording(); | 663 | stopRecording(); |
660 | QMessageBox::message("Vmemo","Vmemo recording has ended"); | 664 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
661 | } | 665 | } |
662 | 666 | ||
663 | 667 | ||
664 | EXPORT_OPIE_APPLET_v1( VMemo ) | 668 | EXPORT_OPIE_APPLET_v1( VMemo ) |
665 | 669 | ||
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp index aec63c3..7832ee0 100644 --- a/core/applets/vtapplet/vt.cpp +++ b/core/applets/vtapplet/vt.cpp | |||
@@ -1,164 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 2 | ** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | 13 | ||
14 | #include "vt.h" | 14 | #include "vt.h" |
15 | 15 | ||
16 | /* OPIE */ | 16 | /* OPIE */ |
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | 23 | ||
24 | /* STD */ | 24 | /* STD */ |
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | #include <linux/vt.h> | 30 | #include <linux/vt.h> |
31 | 31 | ||
32 | VTApplet::VTApplet ( ) | 32 | VTApplet::VTApplet ( ) |
33 | : QObject ( 0, "VTApplet" ) | 33 | : QObject ( 0, "VTApplet" ) |
34 | { | 34 | { |
35 | } | 35 | } |
36 | 36 | ||
37 | VTApplet::~VTApplet ( ) | 37 | VTApplet::~VTApplet ( ) |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | int VTApplet::position ( ) const | 41 | int VTApplet::position ( ) const |
42 | { | 42 | { |
43 | return 2; | 43 | return 2; |
44 | } | 44 | } |
45 | 45 | ||
46 | QString VTApplet::name ( ) const | 46 | QString VTApplet::name ( ) const |
47 | { | 47 | { |
48 | return tr( "VT shortcut" ); | 48 | return tr( "VT shortcut" ); |
49 | } | 49 | } |
50 | 50 | ||
51 | QString VTApplet::text ( ) const | 51 | QString VTApplet::text ( ) const |
52 | { | 52 | { |
53 | return tr( "Terminal" ); | 53 | return tr( "Terminal" ); |
54 | } | 54 | } |
55 | 55 | ||
56 | /* | 56 | /* |
57 | QString VTApplet::tr( const char* s ) const | 57 | QString VTApplet::tr( const char* s ) const |
58 | { | 58 | { |
59 | return qApp->translate( "VTApplet", s, 0 ); | 59 | return qApp->translate( "VTApplet", s, 0 ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QString VTApplet::tr( const char* s, const char* p ) const | 62 | QString VTApplet::tr( const char* s, const char* p ) const |
63 | { | 63 | { |
64 | return qApp->translate( "VTApplet", s, p ); | 64 | return qApp->translate( "VTApplet", s, p ); |
65 | } | 65 | } |
66 | */ | 66 | */ |
67 | 67 | ||
68 | QIconSet VTApplet::icon ( ) const | 68 | QIconSet VTApplet::icon ( ) const |
69 | { | 69 | { |
70 | QPixmap pix; | 70 | QPixmap pix; |
71 | QImage img = Resource::loadImage ( "terminal" ); | 71 | QImage img = Resource::loadImage ( "terminal" ); |
72 | 72 | ||
73 | if ( !img. isNull ( )) | 73 | if ( !img. isNull ( )) |
74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
75 | return pix; | 75 | return pix; |
76 | } | 76 | } |
77 | 77 | ||
78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const | 78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const |
79 | { | 79 | { |
80 | odebug << "VTApplet::popup" << oendl; | 80 | odebug << "VTApplet::popup" << oendl; |
81 | 81 | ||
82 | struct vt_stat vtstat; | 82 | struct vt_stat vtstat; |
83 | #ifdef QT_QWS_DEVFS | ||
84 | int fd = ::open( "/dev/vc/0", O_RDWR ); | ||
85 | #else | ||
83 | int fd = ::open( "/dev/tty0", O_RDWR ); | 86 | int fd = ::open( "/dev/tty0", O_RDWR ); |
87 | #endif | ||
84 | if ( fd == -1 ) return 0; | 88 | if ( fd == -1 ) return 0; |
85 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; | 89 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; |
86 | 90 | ||
87 | m_subMenu = new QPopupMenu( parent ); | 91 | m_subMenu = new QPopupMenu( parent ); |
88 | m_subMenu->setCheckable( true ); | 92 | m_subMenu->setCheckable( true ); |
89 | for ( int i = 1; i < 10; ++i ) | 93 | for ( int i = 1; i < 10; ++i ) |
90 | { | 94 | { |
91 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); | 95 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); |
92 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); | 96 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); |
93 | } | 97 | } |
94 | ::close( fd ); | 98 | ::close( fd ); |
95 | 99 | ||
96 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); | 100 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); |
97 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); | 101 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); |
98 | 102 | ||
99 | return m_subMenu; | 103 | return m_subMenu; |
100 | } | 104 | } |
101 | 105 | ||
102 | 106 | ||
103 | void VTApplet::changeVT( int index ) | 107 | void VTApplet::changeVT( int index ) |
104 | { | 108 | { |
105 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; | 109 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; |
106 | 110 | ||
111 | #ifdef QT_QWS_DEVFS | ||
112 | int fd = ::open("/dev/vc/0", O_RDWR); | ||
113 | #else | ||
107 | int fd = ::open("/dev/tty0", O_RDWR); | 114 | int fd = ::open("/dev/tty0", O_RDWR); |
115 | #endif | ||
108 | if ( fd == -1 ) return; | 116 | if ( fd == -1 ) return; |
109 | ioctl( fd, VT_ACTIVATE, index-500 ); | 117 | ioctl( fd, VT_ACTIVATE, index-500 ); |
110 | } | 118 | } |
111 | 119 | ||
112 | 120 | ||
113 | void VTApplet::updateMenu() | 121 | void VTApplet::updateMenu() |
114 | { | 122 | { |
115 | //odebug << "VTApplet::updateMenu()" << oendl; | 123 | //odebug << "VTApplet::updateMenu()" << oendl; |
116 | 124 | ||
117 | int fd = ::open( "/dev/console", O_RDONLY ); | 125 | int fd = ::open( "/dev/console", O_RDONLY ); |
118 | if ( fd == -1 ) return; | 126 | if ( fd == -1 ) return; |
119 | 127 | ||
120 | for ( int i = 1; i < 10; ++i ) | 128 | for ( int i = 1; i < 10; ++i ) |
121 | { | 129 | { |
122 | int result = ioctl( fd, VT_DISALLOCATE, i ); | 130 | int result = ioctl( fd, VT_DISALLOCATE, i ); |
123 | 131 | ||
124 | /* | 132 | /* |
125 | if ( result == -1 ) | 133 | if ( result == -1 ) |
126 | odebug << "VT " << i << " disallocated == free" << oendl; | 134 | odebug << "VT " << i << " disallocated == free" << oendl; |
127 | else | 135 | else |
128 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; | 136 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; |
129 | */ | 137 | */ |
130 | 138 | ||
131 | m_subMenu->setItemEnabled( 500+i, result == -1 ); | 139 | m_subMenu->setItemEnabled( 500+i, result == -1 ); |
132 | } | 140 | } |
133 | 141 | ||
134 | ::close( fd ); | 142 | ::close( fd ); |
135 | } | 143 | } |
136 | 144 | ||
137 | 145 | ||
138 | void VTApplet::activated() | 146 | void VTApplet::activated() |
139 | { | 147 | { |
140 | odebug << "VTApplet::activated()" << oendl; | 148 | odebug << "VTApplet::activated()" << oendl; |
141 | } | 149 | } |
142 | 150 | ||
143 | 151 | ||
144 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 152 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
145 | { | 153 | { |
146 | *iface = 0; | 154 | *iface = 0; |
147 | if ( uuid == IID_QUnknown ) | 155 | if ( uuid == IID_QUnknown ) |
148 | *iface = this; | 156 | *iface = this; |
149 | else if ( uuid == IID_MenuApplet ) | 157 | else if ( uuid == IID_MenuApplet ) |
150 | *iface = this; | 158 | *iface = this; |
151 | else | 159 | else |
152 | return QS_FALSE; | 160 | return QS_FALSE; |
153 | 161 | ||
154 | if ( *iface ) | 162 | if ( *iface ) |
155 | (*iface)-> addRef ( ); | 163 | (*iface)-> addRef ( ); |
156 | return QS_OK; | 164 | return QS_OK; |
157 | } | 165 | } |
158 | 166 | ||
159 | Q_EXPORT_INTERFACE( ) | 167 | Q_EXPORT_INTERFACE( ) |
160 | { | 168 | { |
161 | Q_CREATE_INSTANCE( VTApplet ) | 169 | Q_CREATE_INSTANCE( VTApplet ) |
162 | } | 170 | } |
163 | 171 | ||
164 | 172 | ||
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 21070bf..9d0bbbf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,1366 +1,1370 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #ifndef QT_NO_SOUND | 26 | #ifndef QT_NO_SOUND |
27 | #include <linux/soundcard.h> | 27 | #include <linux/soundcard.h> |
28 | #endif | 28 | #endif |
29 | #include <math.h> | 29 | #include <math.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qpe/sound.h> | 34 | #include <qpe/sound.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | 38 | ||
39 | #include "odevice.h" | 39 | #include "odevice.h" |
40 | 40 | ||
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | 42 | ||
43 | #ifndef ARRAY_SIZE | 43 | #ifndef ARRAY_SIZE |
44 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 44 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | // _IO and friends are only defined in kernel headers ... | 47 | // _IO and friends are only defined in kernel headers ... |
48 | 48 | ||
49 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 49 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
50 | 50 | ||
51 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 51 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
52 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 52 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
53 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 53 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
54 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 54 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
55 | 55 | ||
56 | using namespace Opie; | 56 | using namespace Opie; |
57 | 57 | ||
58 | class ODeviceData { | 58 | class ODeviceData { |
59 | public: | 59 | public: |
60 | QString m_vendorstr; | 60 | QString m_vendorstr; |
61 | OVendor m_vendor; | 61 | OVendor m_vendor; |
62 | 62 | ||
63 | QString m_modelstr; | 63 | QString m_modelstr; |
64 | OModel m_model; | 64 | OModel m_model; |
65 | 65 | ||
66 | QString m_systemstr; | 66 | QString m_systemstr; |
67 | OSystem m_system; | 67 | OSystem m_system; |
68 | 68 | ||
69 | QString m_sysverstr; | 69 | QString m_sysverstr; |
70 | 70 | ||
71 | Transformation m_rotation; | 71 | Transformation m_rotation; |
72 | ODirection m_direction; | 72 | ODirection m_direction; |
73 | 73 | ||
74 | QValueList <ODeviceButton> *m_buttons; | 74 | QValueList <ODeviceButton> *m_buttons; |
75 | uint m_holdtime; | 75 | uint m_holdtime; |
76 | QStrList *m_cpu_frequencies; | 76 | QStrList *m_cpu_frequencies; |
77 | 77 | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 80 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
81 | protected: | 81 | protected: |
82 | virtual void init ( ); | 82 | virtual void init ( ); |
83 | virtual void initButtons ( ); | 83 | virtual void initButtons ( ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | virtual bool setSoftSuspend ( bool soft ); | 86 | virtual bool setSoftSuspend ( bool soft ); |
87 | 87 | ||
88 | virtual bool setDisplayBrightness ( int b ); | 88 | virtual bool setDisplayBrightness ( int b ); |
89 | virtual int displayBrightnessResolution ( ) const; | 89 | virtual int displayBrightnessResolution ( ) const; |
90 | 90 | ||
91 | virtual void alarmSound ( ); | 91 | virtual void alarmSound ( ); |
92 | 92 | ||
93 | virtual QValueList <OLed> ledList ( ) const; | 93 | virtual QValueList <OLed> ledList ( ) const; |
94 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 94 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
95 | virtual OLedState ledState ( OLed led ) const; | 95 | virtual OLedState ledState ( OLed led ) const; |
96 | virtual bool setLedState ( OLed led, OLedState st ); | 96 | virtual bool setLedState ( OLed led, OLedState st ); |
97 | 97 | ||
98 | virtual bool hasLightSensor ( ) const; | 98 | virtual bool hasLightSensor ( ) const; |
99 | virtual int readLightSensor ( ); | 99 | virtual int readLightSensor ( ); |
100 | virtual int lightSensorResolution ( ) const; | 100 | virtual int lightSensorResolution ( ) const; |
101 | 101 | ||
102 | protected: | 102 | protected: |
103 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 103 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
104 | virtual void timerEvent ( QTimerEvent *te ); | 104 | virtual void timerEvent ( QTimerEvent *te ); |
105 | 105 | ||
106 | int m_power_timer; | 106 | int m_power_timer; |
107 | 107 | ||
108 | OLedState m_leds [2]; | 108 | OLedState m_leds [2]; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | class Jornada : public ODevice { | 111 | class Jornada : public ODevice { |
112 | protected: | 112 | protected: |
113 | virtual void init ( ); | 113 | virtual void init ( ); |
114 | //virtual void initButtons ( ); | 114 | //virtual void initButtons ( ); |
115 | public: | 115 | public: |
116 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
117 | virtual bool setDisplayBrightness ( int b ); | 117 | virtual bool setDisplayBrightness ( int b ); |
118 | virtual int displayBrightnessResolution ( ) const; | 118 | virtual int displayBrightnessResolution ( ) const; |
119 | static bool isJornada(); | 119 | static bool isJornada(); |
120 | 120 | ||
121 | }; | 121 | }; |
122 | 122 | ||
123 | class Zaurus : public ODevice { | 123 | class Zaurus : public ODevice { |
124 | protected: | 124 | protected: |
125 | virtual void init ( ); | 125 | virtual void init ( ); |
126 | virtual void initButtons ( ); | 126 | virtual void initButtons ( ); |
127 | 127 | ||
128 | public: | 128 | public: |
129 | virtual bool setSoftSuspend ( bool soft ); | 129 | virtual bool setSoftSuspend ( bool soft ); |
130 | 130 | ||
131 | virtual bool setDisplayBrightness ( int b ); | 131 | virtual bool setDisplayBrightness ( int b ); |
132 | virtual int displayBrightnessResolution ( ) const; | 132 | virtual int displayBrightnessResolution ( ) const; |
133 | 133 | ||
134 | virtual void alarmSound ( ); | 134 | virtual void alarmSound ( ); |
135 | virtual void keySound ( ); | 135 | virtual void keySound ( ); |
136 | virtual void touchSound ( ); | 136 | virtual void touchSound ( ); |
137 | 137 | ||
138 | virtual QValueList <OLed> ledList ( ) const; | 138 | virtual QValueList <OLed> ledList ( ) const; |
139 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 139 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
140 | virtual OLedState ledState ( OLed led ) const; | 140 | virtual OLedState ledState ( OLed led ) const; |
141 | virtual bool setLedState ( OLed led, OLedState st ); | 141 | virtual bool setLedState ( OLed led, OLedState st ); |
142 | 142 | ||
143 | bool hasHingeSensor() const; | 143 | bool hasHingeSensor() const; |
144 | OHingeStatus readHingeSensor(); | 144 | OHingeStatus readHingeSensor(); |
145 | 145 | ||
146 | static bool isZaurus(); | 146 | static bool isZaurus(); |
147 | 147 | ||
148 | // Does this break BC? | 148 | // Does this break BC? |
149 | virtual bool suspend ( ); | 149 | virtual bool suspend ( ); |
150 | Transformation rotation ( ) const; | 150 | Transformation rotation ( ) const; |
151 | ODirection direction ( ) const; | 151 | ODirection direction ( ) const; |
152 | 152 | ||
153 | protected: | 153 | protected: |
154 | virtual void buzzer ( int snd ); | 154 | virtual void buzzer ( int snd ); |
155 | 155 | ||
156 | OLedState m_leds [1]; | 156 | OLedState m_leds [1]; |
157 | bool m_embedix; | 157 | bool m_embedix; |
158 | void virtual_hook( int id, void *data ); | 158 | void virtual_hook( int id, void *data ); |
159 | }; | 159 | }; |
160 | 160 | ||
161 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 161 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
162 | protected: | 162 | protected: |
163 | virtual void init ( ); | 163 | virtual void init ( ); |
164 | virtual void initButtons ( ); | 164 | virtual void initButtons ( ); |
165 | 165 | ||
166 | public: | 166 | public: |
167 | virtual bool setSoftSuspend ( bool soft ); | 167 | virtual bool setSoftSuspend ( bool soft ); |
168 | virtual bool suspend(); | 168 | virtual bool suspend(); |
169 | 169 | ||
170 | virtual bool setDisplayStatus( bool on ); | 170 | virtual bool setDisplayStatus( bool on ); |
171 | virtual bool setDisplayBrightness ( int b ); | 171 | virtual bool setDisplayBrightness ( int b ); |
172 | virtual int displayBrightnessResolution ( ) const; | 172 | virtual int displayBrightnessResolution ( ) const; |
173 | 173 | ||
174 | virtual void alarmSound ( ); | 174 | virtual void alarmSound ( ); |
175 | 175 | ||
176 | virtual QValueList <OLed> ledList ( ) const; | 176 | virtual QValueList <OLed> ledList ( ) const; |
177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
178 | virtual OLedState ledState ( OLed led ) const; | 178 | virtual OLedState ledState ( OLed led ) const; |
179 | virtual bool setLedState ( OLed led, OLedState st ); | 179 | virtual bool setLedState ( OLed led, OLedState st ); |
180 | 180 | ||
181 | protected: | 181 | protected: |
182 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 182 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
183 | virtual void timerEvent ( QTimerEvent *te ); | 183 | virtual void timerEvent ( QTimerEvent *te ); |
184 | 184 | ||
185 | int m_power_timer; | 185 | int m_power_timer; |
186 | 186 | ||
187 | OLedState m_leds [1]; //FIXME check if really only one | 187 | OLedState m_leds [1]; //FIXME check if really only one |
188 | }; | 188 | }; |
189 | 189 | ||
190 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 190 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
191 | protected: | 191 | protected: |
192 | virtual void init ( ); | 192 | virtual void init ( ); |
193 | 193 | ||
194 | public: | 194 | public: |
195 | virtual bool setSoftSuspend ( bool soft ); | 195 | virtual bool setSoftSuspend ( bool soft ); |
196 | virtual bool suspend ( ); | 196 | virtual bool suspend ( ); |
197 | 197 | ||
198 | virtual bool setDisplayStatus( bool on ); | 198 | virtual bool setDisplayStatus( bool on ); |
199 | virtual bool setDisplayBrightness ( int b ); | 199 | virtual bool setDisplayBrightness ( int b ); |
200 | virtual int displayBrightnessResolution ( ) const; | 200 | virtual int displayBrightnessResolution ( ) const; |
201 | virtual bool setDisplayContrast ( int b ); | 201 | virtual bool setDisplayContrast ( int b ); |
202 | virtual int displayContrastResolution ( ) const; | 202 | virtual int displayContrastResolution ( ) const; |
203 | 203 | ||
204 | protected: | 204 | protected: |
205 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 205 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
206 | virtual void timerEvent ( QTimerEvent *te ); | 206 | virtual void timerEvent ( QTimerEvent *te ); |
207 | 207 | ||
208 | int m_power_timer; | 208 | int m_power_timer; |
209 | }; | 209 | }; |
210 | 210 | ||
211 | struct i_button { | 211 | struct i_button { |
212 | uint model; | 212 | uint model; |
213 | Qt::Key code; | 213 | Qt::Key code; |
214 | char *utext; | 214 | char *utext; |
215 | char *pix; | 215 | char *pix; |
216 | char *fpressedservice; | 216 | char *fpressedservice; |
217 | char *fpressedaction; | 217 | char *fpressedaction; |
218 | char *fheldservice; | 218 | char *fheldservice; |
219 | char *fheldaction; | 219 | char *fheldaction; |
220 | } ipaq_buttons [] = { | 220 | } ipaq_buttons [] = { |
221 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 221 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
222 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 222 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
223 | "devicebuttons/ipaq_calendar", | 223 | "devicebuttons/ipaq_calendar", |
224 | "datebook", "nextView()", | 224 | "datebook", "nextView()", |
225 | "today", "raise()" }, | 225 | "today", "raise()" }, |
226 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 226 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
227 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 227 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
228 | "devicebuttons/ipaq_contact", | 228 | "devicebuttons/ipaq_contact", |
229 | "addressbook", "raise()", | 229 | "addressbook", "raise()", |
230 | "addressbook", "beamBusinessCard()" }, | 230 | "addressbook", "beamBusinessCard()" }, |
231 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 231 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
232 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 232 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
233 | "devicebuttons/ipaq_menu", | 233 | "devicebuttons/ipaq_menu", |
234 | "QPE/TaskBar", "toggleMenu()", | 234 | "QPE/TaskBar", "toggleMenu()", |
235 | "QPE/TaskBar", "toggleStartMenu()" }, | 235 | "QPE/TaskBar", "toggleStartMenu()" }, |
236 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 236 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
237 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 237 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
238 | "devicebuttons/ipaq_mail", | 238 | "devicebuttons/ipaq_mail", |
239 | "mail", "raise()", | 239 | "mail", "raise()", |
240 | "mail", "newMail()" }, | 240 | "mail", "newMail()" }, |
241 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 241 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
242 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 242 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
243 | "devicebuttons/ipaq_home", | 243 | "devicebuttons/ipaq_home", |
244 | "QPE/Launcher", "home()", | 244 | "QPE/Launcher", "home()", |
245 | "buttonsettings", "raise()" }, | 245 | "buttonsettings", "raise()" }, |
246 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 246 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
247 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 247 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
248 | "devicebuttons/ipaq_record", | 248 | "devicebuttons/ipaq_record", |
249 | "QPE/VMemo", "toggleRecord()", | 249 | "QPE/VMemo", "toggleRecord()", |
250 | "sound", "raise()" }, | 250 | "sound", "raise()" }, |
251 | }; | 251 | }; |
252 | 252 | ||
253 | struct z_button { | 253 | struct z_button { |
254 | Qt::Key code; | 254 | Qt::Key code; |
255 | char *utext; | 255 | char *utext; |
256 | char *pix; | 256 | char *pix; |
257 | char *fpressedservice; | 257 | char *fpressedservice; |
258 | char *fpressedaction; | 258 | char *fpressedaction; |
259 | char *fheldservice; | 259 | char *fheldservice; |
260 | char *fheldaction; | 260 | char *fheldaction; |
261 | } z_buttons [] = { | 261 | } z_buttons [] = { |
262 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 262 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
263 | "devicebuttons/z_calendar", | 263 | "devicebuttons/z_calendar", |
264 | "datebook", "nextView()", | 264 | "datebook", "nextView()", |
265 | "today", "raise()" }, | 265 | "today", "raise()" }, |
266 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 266 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
267 | "devicebuttons/z_contact", | 267 | "devicebuttons/z_contact", |
268 | "addressbook", "raise()", | 268 | "addressbook", "raise()", |
269 | "addressbook", "beamBusinessCard()" }, | 269 | "addressbook", "beamBusinessCard()" }, |
270 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 270 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
271 | "devicebuttons/z_home", | 271 | "devicebuttons/z_home", |
272 | "QPE/Launcher", "home()", | 272 | "QPE/Launcher", "home()", |
273 | "buttonsettings", "raise()" }, | 273 | "buttonsettings", "raise()" }, |
274 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 274 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
275 | "devicebuttons/z_menu", | 275 | "devicebuttons/z_menu", |
276 | "QPE/TaskBar", "toggleMenu()", | 276 | "QPE/TaskBar", "toggleMenu()", |
277 | "QPE/TaskBar", "toggleStartMenu()" }, | 277 | "QPE/TaskBar", "toggleStartMenu()" }, |
278 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 278 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
279 | "devicebuttons/z_mail", | 279 | "devicebuttons/z_mail", |
280 | "mail", "raise()", | 280 | "mail", "raise()", |
281 | "mail", "newMail()" }, | 281 | "mail", "newMail()" }, |
282 | }; | 282 | }; |
283 | 283 | ||
284 | struct z_button z_buttons_c700 [] = { | 284 | struct z_button z_buttons_c700 [] = { |
285 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 285 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
286 | "devicebuttons/z_calendar", | 286 | "devicebuttons/z_calendar", |
287 | "datebook", "nextView()", | 287 | "datebook", "nextView()", |
288 | "today", "raise()" }, | 288 | "today", "raise()" }, |
289 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 289 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
290 | "devicebuttons/z_contact", | 290 | "devicebuttons/z_contact", |
291 | "addressbook", "raise()", | 291 | "addressbook", "raise()", |
292 | "addressbook", "beamBusinessCard()" }, | 292 | "addressbook", "beamBusinessCard()" }, |
293 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 293 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
294 | "devicebuttons/z_home", | 294 | "devicebuttons/z_home", |
295 | "QPE/Launcher", "home()", | 295 | "QPE/Launcher", "home()", |
296 | "buttonsettings", "raise()" }, | 296 | "buttonsettings", "raise()" }, |
297 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 297 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
298 | "devicebuttons/z_menu", | 298 | "devicebuttons/z_menu", |
299 | "QPE/TaskBar", "toggleMenu()", | 299 | "QPE/TaskBar", "toggleMenu()", |
300 | "QPE/TaskBar", "toggleStartMenu()" }, | 300 | "QPE/TaskBar", "toggleStartMenu()" }, |
301 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 301 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
302 | "devicebuttons/z_hinge", | 302 | "devicebuttons/z_hinge", |
303 | "QPE/Rotation", "rotateDefault()", | 303 | "QPE/Rotation", "rotateDefault()", |
304 | "QPE/Dummy", "doNothing()" }, | 304 | "QPE/Dummy", "doNothing()" }, |
305 | }; | 305 | }; |
306 | 306 | ||
307 | struct s_button { | 307 | struct s_button { |
308 | uint model; | 308 | uint model; |
309 | Qt::Key code; | 309 | Qt::Key code; |
310 | char *utext; | 310 | char *utext; |
311 | char *pix; | 311 | char *pix; |
312 | char *fpressedservice; | 312 | char *fpressedservice; |
313 | char *fpressedaction; | 313 | char *fpressedaction; |
314 | char *fheldservice; | 314 | char *fheldservice; |
315 | char *fheldaction; | 315 | char *fheldaction; |
316 | } simpad_buttons [] = { | 316 | } simpad_buttons [] = { |
317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 317 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
318 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 318 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
319 | "devicebuttons/simpad_lower_up", | 319 | "devicebuttons/simpad_lower_up", |
320 | "datebook", "nextView()", | 320 | "datebook", "nextView()", |
321 | "today", "raise()" }, | 321 | "today", "raise()" }, |
322 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 322 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
323 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 323 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
324 | "devicebuttons/simpad_lower_down", | 324 | "devicebuttons/simpad_lower_down", |
325 | "addressbook", "raise()", | 325 | "addressbook", "raise()", |
326 | "addressbook", "beamBusinessCard()" }, | 326 | "addressbook", "beamBusinessCard()" }, |
327 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 327 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
328 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 328 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
329 | "devicebuttons/simpad_lower_right", | 329 | "devicebuttons/simpad_lower_right", |
330 | "QPE/TaskBar", "toggleMenu()", | 330 | "QPE/TaskBar", "toggleMenu()", |
331 | "QPE/TaskBar", "toggleStartMenu()" }, | 331 | "QPE/TaskBar", "toggleStartMenu()" }, |
332 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 332 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
333 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 333 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
334 | "devicebuttons/simpad_lower_left", | 334 | "devicebuttons/simpad_lower_left", |
335 | "mail", "raise()", | 335 | "mail", "raise()", |
336 | "mail", "newMail()" }, | 336 | "mail", "newMail()" }, |
337 | 337 | ||
338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
340 | "devicebuttons/simpad_upper_up", | 340 | "devicebuttons/simpad_upper_up", |
341 | "QPE/Launcher", "home()", | 341 | "QPE/Launcher", "home()", |
342 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
345 | "devicebuttons/simpad_upper_down", | 345 | "devicebuttons/simpad_upper_down", |
346 | "addressbook", "raise()", | 346 | "addressbook", "raise()", |
347 | "addressbook", "beamBusinessCard()" }, | 347 | "addressbook", "beamBusinessCard()" }, |
348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
350 | "devicebuttons/simpad_upper_right", | 350 | "devicebuttons/simpad_upper_right", |
351 | "QPE/TaskBar", "toggleMenu()", | 351 | "QPE/TaskBar", "toggleMenu()", |
352 | "QPE/TaskBar", "toggleStartMenu()" }, | 352 | "QPE/TaskBar", "toggleStartMenu()" }, |
353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
355 | "devicebuttons/simpad_upper_left", | 355 | "devicebuttons/simpad_upper_left", |
356 | "QPE/Rotation", "flip()", | 356 | "QPE/Rotation", "flip()", |
357 | "QPE/Rotation", "flip()" }, | 357 | "QPE/Rotation", "flip()" }, |
358 | /* | 358 | /* |
359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
361 | "devicebuttons/simpad_lower_upper", | 361 | "devicebuttons/simpad_lower_upper", |
362 | "QPE/Launcher", "home()", | 362 | "QPE/Launcher", "home()", |
363 | "buttonsettings", "raise()" }, | 363 | "buttonsettings", "raise()" }, |
364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
366 | "devicebuttons/simpad_upper_lower", | 366 | "devicebuttons/simpad_upper_lower", |
367 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
368 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
369 | */ | 369 | */ |
370 | }; | 370 | }; |
371 | 371 | ||
372 | class Yopy : public ODevice { | 372 | class Yopy : public ODevice { |
373 | protected: | 373 | protected: |
374 | virtual void init ( ); | 374 | virtual void init ( ); |
375 | virtual void initButtons ( ); | 375 | virtual void initButtons ( ); |
376 | 376 | ||
377 | public: | 377 | public: |
378 | virtual bool suspend ( ); | 378 | virtual bool suspend ( ); |
379 | 379 | ||
380 | virtual bool setDisplayBrightness ( int b ); | 380 | virtual bool setDisplayBrightness ( int b ); |
381 | virtual int displayBrightnessResolution ( ) const; | 381 | virtual int displayBrightnessResolution ( ) const; |
382 | 382 | ||
383 | static bool isYopy ( ); | 383 | static bool isYopy ( ); |
384 | }; | 384 | }; |
385 | 385 | ||
386 | struct yopy_button { | 386 | struct yopy_button { |
387 | Qt::Key code; | 387 | Qt::Key code; |
388 | char *utext; | 388 | char *utext; |
389 | char *pix; | 389 | char *pix; |
390 | char *fpressedservice; | 390 | char *fpressedservice; |
391 | char *fpressedaction; | 391 | char *fpressedaction; |
392 | char *fheldservice; | 392 | char *fheldservice; |
393 | char *fheldaction; | 393 | char *fheldaction; |
394 | } yopy_buttons [] = { | 394 | } yopy_buttons [] = { |
395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
396 | "devicebuttons/yopy_action", | 396 | "devicebuttons/yopy_action", |
397 | "datebook", "nextView()", | 397 | "datebook", "nextView()", |
398 | "today", "raise()" }, | 398 | "today", "raise()" }, |
399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
400 | "devicebuttons/yopy_ok", | 400 | "devicebuttons/yopy_ok", |
401 | "addressbook", "raise()", | 401 | "addressbook", "raise()", |
402 | "addressbook", "beamBusinessCard()" }, | 402 | "addressbook", "beamBusinessCard()" }, |
403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
404 | "devicebuttons/yopy_end", | 404 | "devicebuttons/yopy_end", |
405 | "QPE/Launcher", "home()", | 405 | "QPE/Launcher", "home()", |
406 | "buttonsettings", "raise()" }, | 406 | "buttonsettings", "raise()" }, |
407 | }; | 407 | }; |
408 | 408 | ||
409 | static QCString makeChannel ( const char *str ) | 409 | static QCString makeChannel ( const char *str ) |
410 | { | 410 | { |
411 | if ( str && !::strchr ( str, '/' )) | 411 | if ( str && !::strchr ( str, '/' )) |
412 | return QCString ( "QPE/Application/" ) + str; | 412 | return QCString ( "QPE/Application/" ) + str; |
413 | else | 413 | else |
414 | return str; | 414 | return str; |
415 | } | 415 | } |
416 | 416 | ||
417 | static inline bool isQWS() | 417 | static inline bool isQWS() |
418 | { | 418 | { |
419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
420 | } | 420 | } |
421 | 421 | ||
422 | ODevice *ODevice::inst ( ) | 422 | ODevice *ODevice::inst ( ) |
423 | { | 423 | { |
424 | static ODevice *dev = 0; | 424 | static ODevice *dev = 0; |
425 | 425 | ||
426 | if ( !dev ) { | 426 | if ( !dev ) { |
427 | if ( QFile::exists ( "/proc/hal/model" )) | 427 | if ( QFile::exists ( "/proc/hal/model" )) |
428 | dev = new iPAQ ( ); | 428 | dev = new iPAQ ( ); |
429 | else if ( Zaurus::isZaurus() ) | 429 | else if ( Zaurus::isZaurus() ) |
430 | dev = new Zaurus ( ); | 430 | dev = new Zaurus ( ); |
431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
432 | dev = new SIMpad ( ); | 432 | dev = new SIMpad ( ); |
433 | else if ( Yopy::isYopy() ) | 433 | else if ( Yopy::isYopy() ) |
434 | dev = new Yopy ( ); | 434 | dev = new Yopy ( ); |
435 | else if ( Jornada::isJornada() ) | 435 | else if ( Jornada::isJornada() ) |
436 | dev = new Jornada ( ); | 436 | dev = new Jornada ( ); |
437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) | 437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) |
438 | dev = new Ramses ( ); | 438 | dev = new Ramses ( ); |
439 | else | 439 | else |
440 | dev = new ODevice ( ); | 440 | dev = new ODevice ( ); |
441 | dev-> init ( ); | 441 | dev-> init ( ); |
442 | } | 442 | } |
443 | return dev; | 443 | return dev; |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | /************************************************** | 447 | /************************************************** |
448 | * | 448 | * |
449 | * common | 449 | * common |
450 | * | 450 | * |
451 | **************************************************/ | 451 | **************************************************/ |
452 | 452 | ||
453 | 453 | ||
454 | ODevice::ODevice ( ) | 454 | ODevice::ODevice ( ) |
455 | { | 455 | { |
456 | d = new ODeviceData; | 456 | d = new ODeviceData; |
457 | 457 | ||
458 | d-> m_modelstr = "Unknown"; | 458 | d-> m_modelstr = "Unknown"; |
459 | d-> m_model = Model_Unknown; | 459 | d-> m_model = Model_Unknown; |
460 | d-> m_vendorstr = "Unknown"; | 460 | d-> m_vendorstr = "Unknown"; |
461 | d-> m_vendor = Vendor_Unknown; | 461 | d-> m_vendor = Vendor_Unknown; |
462 | d-> m_systemstr = "Unknown"; | 462 | d-> m_systemstr = "Unknown"; |
463 | d-> m_system = System_Unknown; | 463 | d-> m_system = System_Unknown; |
464 | d-> m_sysverstr = "0.0"; | 464 | d-> m_sysverstr = "0.0"; |
465 | d-> m_rotation = Rot0; | 465 | d-> m_rotation = Rot0; |
466 | d-> m_direction = CW; | 466 | d-> m_direction = CW; |
467 | 467 | ||
468 | d-> m_holdtime = 1000; // 1000ms | 468 | d-> m_holdtime = 1000; // 1000ms |
469 | d-> m_buttons = 0; | 469 | d-> m_buttons = 0; |
470 | d-> m_cpu_frequencies = new QStrList; | 470 | d-> m_cpu_frequencies = new QStrList; |
471 | } | 471 | } |
472 | 472 | ||
473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
474 | { | 474 | { |
475 | if ( msg == "deviceButtonMappingChanged()" ) { | 475 | if ( msg == "deviceButtonMappingChanged()" ) { |
476 | reloadButtonMapping ( ); | 476 | reloadButtonMapping ( ); |
477 | } | 477 | } |
478 | } | 478 | } |
479 | 479 | ||
480 | void ODevice::init ( ) | 480 | void ODevice::init ( ) |
481 | { | 481 | { |
482 | } | 482 | } |
483 | 483 | ||
484 | /** | 484 | /** |
485 | * This method initialises the button mapping | 485 | * This method initialises the button mapping |
486 | */ | 486 | */ |
487 | void ODevice::initButtons ( ) | 487 | void ODevice::initButtons ( ) |
488 | { | 488 | { |
489 | if ( d-> m_buttons ) | 489 | if ( d-> m_buttons ) |
490 | return; | 490 | return; |
491 | 491 | ||
492 | // Simulation uses iPAQ 3660 device buttons | 492 | // Simulation uses iPAQ 3660 device buttons |
493 | 493 | ||
494 | qDebug ( "init Buttons" ); | 494 | qDebug ( "init Buttons" ); |
495 | d-> m_buttons = new QValueList <ODeviceButton>; | 495 | d-> m_buttons = new QValueList <ODeviceButton>; |
496 | 496 | ||
497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
498 | i_button *ib = ipaq_buttons + i; | 498 | i_button *ib = ipaq_buttons + i; |
499 | ODeviceButton b; | 499 | ODeviceButton b; |
500 | 500 | ||
501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
502 | b. setKeycode ( ib-> code ); | 502 | b. setKeycode ( ib-> code ); |
503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
507 | d-> m_buttons-> append ( b ); | 507 | d-> m_buttons-> append ( b ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | reloadButtonMapping ( ); | 510 | reloadButtonMapping ( ); |
511 | 511 | ||
512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
514 | } | 514 | } |
515 | 515 | ||
516 | ODevice::~ODevice ( ) | 516 | ODevice::~ODevice ( ) |
517 | { | 517 | { |
518 | // we leak m_devicebuttons and m_cpu_frequency | 518 | // we leak m_devicebuttons and m_cpu_frequency |
519 | // but it's a singleton and it is not so importantant | 519 | // but it's a singleton and it is not so importantant |
520 | // -zecke | 520 | // -zecke |
521 | delete d; | 521 | delete d; |
522 | } | 522 | } |
523 | 523 | ||
524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
525 | { | 525 | { |
526 | return false; | 526 | return false; |
527 | } | 527 | } |
528 | 528 | ||
529 | //#include <linux/apm_bios.h> | 529 | //#include <linux/apm_bios.h> |
530 | 530 | ||
531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * This method will try to suspend the device | 534 | * This method will try to suspend the device |
535 | * It only works if the user is the QWS Server and the apm application | 535 | * It only works if the user is the QWS Server and the apm application |
536 | * is installed. | 536 | * is installed. |
537 | * It tries to suspend and then waits some time cause some distributions | 537 | * It tries to suspend and then waits some time cause some distributions |
538 | * do have asynchronus apm implementations. | 538 | * do have asynchronus apm implementations. |
539 | * This method will either fail and return false or it'll suspend the | 539 | * This method will either fail and return false or it'll suspend the |
540 | * device and return once the device got woken up | 540 | * device and return once the device got woken up |
541 | * | 541 | * |
542 | * @return if the device got suspended | 542 | * @return if the device got suspended |
543 | */ | 543 | */ |
544 | bool ODevice::suspend ( ) | 544 | bool ODevice::suspend ( ) |
545 | { | 545 | { |
546 | qDebug("ODevice::suspend"); | 546 | qDebug("ODevice::suspend"); |
547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
548 | return false; | 548 | return false; |
549 | 549 | ||
550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
551 | return false; | 551 | return false; |
552 | 552 | ||
553 | bool res = false; | 553 | bool res = false; |
554 | 554 | ||
555 | struct timeval tvs, tvn; | 555 | struct timeval tvs, tvn; |
556 | ::gettimeofday ( &tvs, 0 ); | 556 | ::gettimeofday ( &tvs, 0 ); |
557 | 557 | ||
558 | ::sync ( ); // flush fs caches | 558 | ::sync ( ); // flush fs caches |
559 | res = ( ::system ( "apm --suspend" ) == 0 ); | 559 | res = ( ::system ( "apm --suspend" ) == 0 ); |
560 | 560 | ||
561 | // This is needed because the iPAQ apm implementation is asynchronous and we | 561 | // This is needed because the iPAQ apm implementation is asynchronous and we |
562 | // can not be sure when exactly the device is really suspended | 562 | // can not be sure when exactly the device is really suspended |
563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
564 | 564 | ||
565 | if ( res ) { | 565 | if ( res ) { |
566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
567 | ::usleep ( 200 * 1000 ); | 567 | ::usleep ( 200 * 1000 ); |
568 | ::gettimeofday ( &tvn, 0 ); | 568 | ::gettimeofday ( &tvn, 0 ); |
569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
570 | } | 570 | } |
571 | 571 | ||
572 | return res; | 572 | return res; |
573 | } | 573 | } |
574 | 574 | ||
575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
576 | 576 | ||
577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
578 | 578 | ||
579 | /* VESA Blanking Levels */ | 579 | /* VESA Blanking Levels */ |
580 | #define VESA_NO_BLANKING 0 | 580 | #define VESA_NO_BLANKING 0 |
581 | #define VESA_VSYNC_SUSPEND 1 | 581 | #define VESA_VSYNC_SUSPEND 1 |
582 | #define VESA_HSYNC_SUSPEND 2 | 582 | #define VESA_HSYNC_SUSPEND 2 |
583 | #define VESA_POWERDOWN 3 | 583 | #define VESA_POWERDOWN 3 |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * This sets the display on or off | 586 | * This sets the display on or off |
587 | */ | 587 | */ |
588 | bool ODevice::setDisplayStatus ( bool on ) | 588 | bool ODevice::setDisplayStatus ( bool on ) |
589 | { | 589 | { |
590 | qDebug("ODevice::setDisplayStatus(%d)", on); | 590 | qDebug("ODevice::setDisplayStatus(%d)", on); |
591 | 591 | ||
592 | if ( d-> m_model == Model_Unknown ) | 592 | if ( d-> m_model == Model_Unknown ) |
593 | return false; | 593 | return false; |
594 | 594 | ||
595 | bool res = false; | 595 | bool res = false; |
596 | int fd; | 596 | int fd; |
597 | 597 | ||
598 | #ifdef QT_QWS_DEVFS | ||
599 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
600 | #else | ||
598 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 601 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
602 | #endif | ||
599 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 603 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
600 | ::close ( fd ); | 604 | ::close ( fd ); |
601 | } | 605 | } |
602 | return res; | 606 | return res; |
603 | } | 607 | } |
604 | 608 | ||
605 | /** | 609 | /** |
606 | * This sets the display brightness | 610 | * This sets the display brightness |
607 | * | 611 | * |
608 | * @param p The brightness to be set on a scale from 0 to 255 | 612 | * @param p The brightness to be set on a scale from 0 to 255 |
609 | * @return success or failure | 613 | * @return success or failure |
610 | */ | 614 | */ |
611 | bool ODevice::setDisplayBrightness ( int p) | 615 | bool ODevice::setDisplayBrightness ( int p) |
612 | { | 616 | { |
613 | Q_UNUSED( p ) | 617 | Q_UNUSED( p ) |
614 | return false; | 618 | return false; |
615 | } | 619 | } |
616 | 620 | ||
617 | /** | 621 | /** |
618 | * @return returns the number of steppings on the brightness slider | 622 | * @return returns the number of steppings on the brightness slider |
619 | * in the Light-'n-Power settings. | 623 | * in the Light-'n-Power settings. |
620 | */ | 624 | */ |
621 | int ODevice::displayBrightnessResolution ( ) const | 625 | int ODevice::displayBrightnessResolution ( ) const |
622 | { | 626 | { |
623 | return 16; | 627 | return 16; |
624 | } | 628 | } |
625 | 629 | ||
626 | /** | 630 | /** |
627 | * This sets the display contrast | 631 | * This sets the display contrast |
628 | * @param p The contrast to be set on a scale from 0 to 255 | 632 | * @param p The contrast to be set on a scale from 0 to 255 |
629 | * @return success or failure | 633 | * @return success or failure |
630 | */ | 634 | */ |
631 | bool ODevice::setDisplayContrast ( int p) | 635 | bool ODevice::setDisplayContrast ( int p) |
632 | { | 636 | { |
633 | Q_UNUSED( p ) | 637 | Q_UNUSED( p ) |
634 | return false; | 638 | return false; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * @return return the max value for the brightness settings slider | 642 | * @return return the max value for the brightness settings slider |
639 | * or 0 if the device doesn't support setting of a contrast | 643 | * or 0 if the device doesn't support setting of a contrast |
640 | */ | 644 | */ |
641 | int ODevice::displayContrastResolution ( ) const | 645 | int ODevice::displayContrastResolution ( ) const |
642 | { | 646 | { |
643 | return 0; | 647 | return 0; |
644 | } | 648 | } |
645 | 649 | ||
646 | /** | 650 | /** |
647 | * This returns the vendor as string | 651 | * This returns the vendor as string |
648 | * @return Vendor as QString | 652 | * @return Vendor as QString |
649 | */ | 653 | */ |
650 | QString ODevice::vendorString ( ) const | 654 | QString ODevice::vendorString ( ) const |
651 | { | 655 | { |
652 | return d-> m_vendorstr; | 656 | return d-> m_vendorstr; |
653 | } | 657 | } |
654 | 658 | ||
655 | /** | 659 | /** |
656 | * This returns the vendor as one of the values of OVendor | 660 | * This returns the vendor as one of the values of OVendor |
657 | * @return OVendor | 661 | * @return OVendor |
658 | */ | 662 | */ |
659 | OVendor ODevice::vendor ( ) const | 663 | OVendor ODevice::vendor ( ) const |
660 | { | 664 | { |
661 | return d-> m_vendor; | 665 | return d-> m_vendor; |
662 | } | 666 | } |
663 | 667 | ||
664 | /** | 668 | /** |
665 | * This returns the model as a string | 669 | * This returns the model as a string |
666 | * @return A string representing the model | 670 | * @return A string representing the model |
667 | */ | 671 | */ |
668 | QString ODevice::modelString ( ) const | 672 | QString ODevice::modelString ( ) const |
669 | { | 673 | { |
670 | return d-> m_modelstr; | 674 | return d-> m_modelstr; |
671 | } | 675 | } |
672 | 676 | ||
673 | /** | 677 | /** |
674 | * This does return the OModel used | 678 | * This does return the OModel used |
675 | */ | 679 | */ |
676 | OModel ODevice::model ( ) const | 680 | OModel ODevice::model ( ) const |
677 | { | 681 | { |
678 | return d-> m_model; | 682 | return d-> m_model; |
679 | } | 683 | } |
680 | 684 | ||
681 | /** | 685 | /** |
682 | * This does return the systen name | 686 | * This does return the systen name |
683 | */ | 687 | */ |
684 | QString ODevice::systemString ( ) const | 688 | QString ODevice::systemString ( ) const |
685 | { | 689 | { |
686 | return d-> m_systemstr; | 690 | return d-> m_systemstr; |
687 | } | 691 | } |
688 | 692 | ||
689 | /** | 693 | /** |
690 | * Return System as OSystem value | 694 | * Return System as OSystem value |
691 | */ | 695 | */ |
692 | OSystem ODevice::system ( ) const | 696 | OSystem ODevice::system ( ) const |
693 | { | 697 | { |
694 | return d-> m_system; | 698 | return d-> m_system; |
695 | } | 699 | } |
696 | 700 | ||
697 | /** | 701 | /** |
698 | * @return the version string of the base system | 702 | * @return the version string of the base system |
699 | */ | 703 | */ |
700 | QString ODevice::systemVersionString ( ) const | 704 | QString ODevice::systemVersionString ( ) const |
701 | { | 705 | { |
702 | return d-> m_sysverstr; | 706 | return d-> m_sysverstr; |
703 | } | 707 | } |
704 | 708 | ||
705 | /** | 709 | /** |
706 | * @return the current Transformation | 710 | * @return the current Transformation |
707 | */ | 711 | */ |
708 | Transformation ODevice::rotation ( ) const | 712 | Transformation ODevice::rotation ( ) const |
709 | { | 713 | { |
710 | VirtRotation rot; | 714 | VirtRotation rot; |
711 | ODevice* that =(ODevice* )this; | 715 | ODevice* that =(ODevice* )this; |
712 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); | 716 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); |
713 | return rot.trans; | 717 | return rot.trans; |
714 | } | 718 | } |
715 | 719 | ||
716 | /** | 720 | /** |
717 | * @return the current rotation direction | 721 | * @return the current rotation direction |
718 | */ | 722 | */ |
719 | ODirection ODevice::direction ( ) const | 723 | ODirection ODevice::direction ( ) const |
720 | { | 724 | { |
721 | VirtDirection dir; | 725 | VirtDirection dir; |
722 | ODevice* that =(ODevice* )this; | 726 | ODevice* that =(ODevice* )this; |
723 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); | 727 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); |
724 | return dir.direct; | 728 | return dir.direct; |
725 | } | 729 | } |
726 | 730 | ||
727 | /** | 731 | /** |
728 | * This plays an alarmSound | 732 | * This plays an alarmSound |
729 | */ | 733 | */ |
730 | void ODevice::alarmSound ( ) | 734 | void ODevice::alarmSound ( ) |
731 | { | 735 | { |
732 | #ifndef QT_NO_SOUND | 736 | #ifndef QT_NO_SOUND |
733 | static Sound snd ( "alarm" ); | 737 | static Sound snd ( "alarm" ); |
734 | 738 | ||
735 | if ( snd. isFinished ( )) | 739 | if ( snd. isFinished ( )) |
736 | snd. play ( ); | 740 | snd. play ( ); |
737 | #endif | 741 | #endif |
738 | } | 742 | } |
739 | 743 | ||
740 | /** | 744 | /** |
741 | * This plays a key sound | 745 | * This plays a key sound |
742 | */ | 746 | */ |
743 | void ODevice::keySound ( ) | 747 | void ODevice::keySound ( ) |
744 | { | 748 | { |
745 | #ifndef QT_NO_SOUND | 749 | #ifndef QT_NO_SOUND |
746 | static Sound snd ( "keysound" ); | 750 | static Sound snd ( "keysound" ); |
747 | 751 | ||
748 | if ( snd. isFinished ( )) | 752 | if ( snd. isFinished ( )) |
749 | snd. play ( ); | 753 | snd. play ( ); |
750 | #endif | 754 | #endif |
751 | } | 755 | } |
752 | 756 | ||
753 | /** | 757 | /** |
754 | * This plays a touch sound | 758 | * This plays a touch sound |
755 | */ | 759 | */ |
756 | void ODevice::touchSound ( ) | 760 | void ODevice::touchSound ( ) |
757 | { | 761 | { |
758 | #ifndef QT_NO_SOUND | 762 | #ifndef QT_NO_SOUND |
759 | static Sound snd ( "touchsound" ); | 763 | static Sound snd ( "touchsound" ); |
760 | 764 | ||
761 | if ( snd. isFinished ( )) | 765 | if ( snd. isFinished ( )) |
762 | snd. play ( ); | 766 | snd. play ( ); |
763 | #endif | 767 | #endif |
764 | } | 768 | } |
765 | 769 | ||
766 | /** | 770 | /** |
767 | * This method will return a list of leds | 771 | * This method will return a list of leds |
768 | * available on this device | 772 | * available on this device |
769 | * @return a list of LEDs. | 773 | * @return a list of LEDs. |
770 | */ | 774 | */ |
771 | QValueList <OLed> ODevice::ledList ( ) const | 775 | QValueList <OLed> ODevice::ledList ( ) const |
772 | { | 776 | { |
773 | return QValueList <OLed> ( ); | 777 | return QValueList <OLed> ( ); |
774 | } | 778 | } |
775 | 779 | ||
776 | /** | 780 | /** |
777 | * This does return the state of the LEDs | 781 | * This does return the state of the LEDs |
778 | */ | 782 | */ |
779 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 783 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
780 | { | 784 | { |
781 | return QValueList <OLedState> ( ); | 785 | return QValueList <OLedState> ( ); |
782 | } | 786 | } |
783 | 787 | ||
784 | /** | 788 | /** |
785 | * @return the state for a given OLed | 789 | * @return the state for a given OLed |
786 | */ | 790 | */ |
787 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 791 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
788 | { | 792 | { |
789 | return Led_Off; | 793 | return Led_Off; |
790 | } | 794 | } |
791 | 795 | ||
792 | /** | 796 | /** |
793 | * Set the state for a LED | 797 | * Set the state for a LED |
794 | * @param which Which OLed to use | 798 | * @param which Which OLed to use |
795 | * @param st The state to set | 799 | * @param st The state to set |
796 | * @return success or failure | 800 | * @return success or failure |
797 | */ | 801 | */ |
798 | bool ODevice::setLedState ( OLed which, OLedState st ) | 802 | bool ODevice::setLedState ( OLed which, OLedState st ) |
799 | { | 803 | { |
800 | Q_UNUSED( which ) | 804 | Q_UNUSED( which ) |
801 | Q_UNUSED( st ) | 805 | Q_UNUSED( st ) |
802 | return false; | 806 | return false; |
803 | } | 807 | } |
804 | 808 | ||
805 | /** | 809 | /** |
806 | * @return if the device has a light sensor | 810 | * @return if the device has a light sensor |
807 | */ | 811 | */ |
808 | bool ODevice::hasLightSensor ( ) const | 812 | bool ODevice::hasLightSensor ( ) const |
809 | { | 813 | { |
810 | return false; | 814 | return false; |
811 | } | 815 | } |
812 | 816 | ||
813 | /** | 817 | /** |
814 | * @return a value from the light sensor | 818 | * @return a value from the light sensor |
815 | */ | 819 | */ |
816 | int ODevice::readLightSensor ( ) | 820 | int ODevice::readLightSensor ( ) |
817 | { | 821 | { |
818 | return -1; | 822 | return -1; |
819 | } | 823 | } |
820 | 824 | ||
821 | /** | 825 | /** |
822 | * @return the light sensor resolution | 826 | * @return the light sensor resolution |
823 | */ | 827 | */ |
824 | int ODevice::lightSensorResolution ( ) const | 828 | int ODevice::lightSensorResolution ( ) const |
825 | { | 829 | { |
826 | return 0; | 830 | return 0; |
827 | } | 831 | } |
828 | 832 | ||
829 | /** | 833 | /** |
830 | * @return if the device has a hinge sensor | 834 | * @return if the device has a hinge sensor |
831 | */ | 835 | */ |
832 | bool ODevice::hasHingeSensor ( ) const | 836 | bool ODevice::hasHingeSensor ( ) const |
833 | { | 837 | { |
834 | VirtHasHinge hing; | 838 | VirtHasHinge hing; |
835 | ODevice* that =(ODevice* )this; | 839 | ODevice* that =(ODevice* )this; |
836 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); | 840 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); |
837 | return hing.hasHinge; | 841 | return hing.hasHinge; |
838 | } | 842 | } |
839 | 843 | ||
840 | /** | 844 | /** |
841 | * @return a value from the hinge sensor | 845 | * @return a value from the hinge sensor |
842 | */ | 846 | */ |
843 | OHingeStatus ODevice::readHingeSensor ( ) | 847 | OHingeStatus ODevice::readHingeSensor ( ) |
844 | { | 848 | { |
845 | VirtHingeStatus hing; | 849 | VirtHingeStatus hing; |
846 | virtual_hook( VIRTUAL_HINGE, &hing ); | 850 | virtual_hook( VIRTUAL_HINGE, &hing ); |
847 | return hing.hingeStat; | 851 | return hing.hingeStat; |
848 | } | 852 | } |
849 | 853 | ||
850 | /** | 854 | /** |
851 | * @return a list with CPU frequencies supported by the hardware | 855 | * @return a list with CPU frequencies supported by the hardware |
852 | */ | 856 | */ |
853 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 857 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
854 | { | 858 | { |
855 | return *d->m_cpu_frequencies; | 859 | return *d->m_cpu_frequencies; |
856 | } | 860 | } |
857 | 861 | ||
858 | 862 | ||
859 | /** | 863 | /** |
860 | * Set desired CPU frequency | 864 | * Set desired CPU frequency |
861 | * | 865 | * |
862 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 866 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
863 | */ | 867 | */ |
864 | bool ODevice::setCurrentCpuFrequency(uint index) | 868 | bool ODevice::setCurrentCpuFrequency(uint index) |
865 | { | 869 | { |
866 | if (index >= d->m_cpu_frequencies->count()) | 870 | if (index >= d->m_cpu_frequencies->count()) |
867 | return false; | 871 | return false; |
868 | 872 | ||
869 | char *freq = d->m_cpu_frequencies->at(index); | 873 | char *freq = d->m_cpu_frequencies->at(index); |
870 | qWarning("set freq to %s", freq); | 874 | qWarning("set freq to %s", freq); |
871 | 875 | ||
872 | int fd; | 876 | int fd; |
873 | 877 | ||
874 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 878 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
875 | char writeCommand[50]; | 879 | char writeCommand[50]; |
876 | const int count = sprintf(writeCommand, "%s\n", freq); | 880 | const int count = sprintf(writeCommand, "%s\n", freq); |
877 | int res = (::write(fd, writeCommand, count) != -1); | 881 | int res = (::write(fd, writeCommand, count) != -1); |
878 | ::close(fd); | 882 | ::close(fd); |
879 | return res; | 883 | return res; |
880 | } | 884 | } |
881 | 885 | ||
882 | return false; | 886 | return false; |
883 | } | 887 | } |
884 | 888 | ||
885 | 889 | ||
886 | /** | 890 | /** |
887 | * @return a list of hardware buttons | 891 | * @return a list of hardware buttons |
888 | */ | 892 | */ |
889 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 893 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
890 | { | 894 | { |
891 | initButtons ( ); | 895 | initButtons ( ); |
892 | 896 | ||
893 | return *d-> m_buttons; | 897 | return *d-> m_buttons; |
894 | } | 898 | } |
895 | 899 | ||
896 | /** | 900 | /** |
897 | * @return The amount of time that would count as a hold | 901 | * @return The amount of time that would count as a hold |
898 | */ | 902 | */ |
899 | uint ODevice::buttonHoldTime ( ) const | 903 | uint ODevice::buttonHoldTime ( ) const |
900 | { | 904 | { |
901 | return d-> m_holdtime; | 905 | return d-> m_holdtime; |
902 | } | 906 | } |
903 | 907 | ||
904 | /** | 908 | /** |
905 | * This method return a ODeviceButton for a key code | 909 | * This method return a ODeviceButton for a key code |
906 | * or 0 if no special hardware button is available for the device | 910 | * or 0 if no special hardware button is available for the device |
907 | * | 911 | * |
908 | * @return The devicebutton or 0l | 912 | * @return The devicebutton or 0l |
909 | * @see ODeviceButton | 913 | * @see ODeviceButton |
910 | */ | 914 | */ |
911 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 915 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
912 | { | 916 | { |
913 | initButtons ( ); | 917 | initButtons ( ); |
914 | 918 | ||
915 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 919 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
916 | if ( (*it). keycode ( ) == code ) | 920 | if ( (*it). keycode ( ) == code ) |
917 | return &(*it); | 921 | return &(*it); |
918 | } | 922 | } |
919 | return 0; | 923 | return 0; |
920 | } | 924 | } |
921 | 925 | ||
922 | void ODevice::reloadButtonMapping ( ) | 926 | void ODevice::reloadButtonMapping ( ) |
923 | { | 927 | { |
924 | initButtons ( ); | 928 | initButtons ( ); |
925 | 929 | ||
926 | Config cfg ( "ButtonSettings" ); | 930 | Config cfg ( "ButtonSettings" ); |
927 | 931 | ||
928 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 932 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
929 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 933 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
930 | QString group = "Button" + QString::number ( i ); | 934 | QString group = "Button" + QString::number ( i ); |
931 | 935 | ||
932 | QCString pch, hch; | 936 | QCString pch, hch; |
933 | QCString pm, hm; | 937 | QCString pm, hm; |
934 | QByteArray pdata, hdata; | 938 | QByteArray pdata, hdata; |
935 | 939 | ||
936 | if ( cfg. hasGroup ( group )) { | 940 | if ( cfg. hasGroup ( group )) { |
937 | cfg. setGroup ( group ); | 941 | cfg. setGroup ( group ); |
938 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 942 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
939 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 943 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
940 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 944 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
941 | 945 | ||
942 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 946 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
943 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 947 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
944 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 948 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
945 | } | 949 | } |
946 | 950 | ||
947 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 951 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
948 | 952 | ||
949 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 953 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
950 | } | 954 | } |
951 | } | 955 | } |
952 | 956 | ||
953 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 957 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
954 | { | 958 | { |
955 | initButtons ( ); | 959 | initButtons ( ); |
956 | 960 | ||
957 | QString mb_chan; | 961 | QString mb_chan; |
958 | 962 | ||
959 | if ( button >= (int) d-> m_buttons-> count ( )) | 963 | if ( button >= (int) d-> m_buttons-> count ( )) |
960 | return; | 964 | return; |
961 | 965 | ||
962 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 966 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
963 | b. setPressedAction ( action ); | 967 | b. setPressedAction ( action ); |
964 | 968 | ||
965 | mb_chan=b. pressedAction ( ). channel ( ); | 969 | mb_chan=b. pressedAction ( ). channel ( ); |
966 | 970 | ||
967 | Config buttonFile ( "ButtonSettings" ); | 971 | Config buttonFile ( "ButtonSettings" ); |
968 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 972 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
969 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 973 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
970 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 974 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
971 | 975 | ||
972 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 976 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
973 | 977 | ||
974 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 978 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
975 | } | 979 | } |
976 | 980 | ||
977 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 981 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
978 | { | 982 | { |
979 | initButtons ( ); | 983 | initButtons ( ); |
980 | 984 | ||
981 | if ( button >= (int) d-> m_buttons-> count ( )) | 985 | if ( button >= (int) d-> m_buttons-> count ( )) |
982 | return; | 986 | return; |
983 | 987 | ||
984 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 988 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
985 | b. setHeldAction ( action ); | 989 | b. setHeldAction ( action ); |
986 | 990 | ||
987 | Config buttonFile ( "ButtonSettings" ); | 991 | Config buttonFile ( "ButtonSettings" ); |
988 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 992 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
989 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 993 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
990 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 994 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
991 | 995 | ||
992 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 996 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
993 | 997 | ||
994 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 998 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
995 | } | 999 | } |
996 | void ODevice::virtual_hook(int id, void* data){ | 1000 | void ODevice::virtual_hook(int id, void* data){ |
997 | switch( id ) { | 1001 | switch( id ) { |
998 | case VIRTUAL_ROTATION:{ | 1002 | case VIRTUAL_ROTATION:{ |
999 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 1003 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
1000 | rot->trans = d->m_rotation; | 1004 | rot->trans = d->m_rotation; |
1001 | break; | 1005 | break; |
1002 | } | 1006 | } |
1003 | case VIRTUAL_DIRECTION:{ | 1007 | case VIRTUAL_DIRECTION:{ |
1004 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 1008 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
1005 | dir->direct = d->m_direction; | 1009 | dir->direct = d->m_direction; |
1006 | break; | 1010 | break; |
1007 | } | 1011 | } |
1008 | case VIRTUAL_HAS_HINGE:{ | 1012 | case VIRTUAL_HAS_HINGE:{ |
1009 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 1013 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
1010 | hin->hasHinge = false; | 1014 | hin->hasHinge = false; |
1011 | break; | 1015 | break; |
1012 | } | 1016 | } |
1013 | case VIRTUAL_HINGE:{ | 1017 | case VIRTUAL_HINGE:{ |
1014 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 1018 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
1015 | hin->hingeStat = CASE_UNKNOWN; | 1019 | hin->hingeStat = CASE_UNKNOWN; |
1016 | break; | 1020 | break; |
1017 | } | 1021 | } |
1018 | } | 1022 | } |
1019 | } | 1023 | } |
1020 | 1024 | ||
1021 | /************************************************** | 1025 | /************************************************** |
1022 | * | 1026 | * |
1023 | * Yopy 3500/3700 | 1027 | * Yopy 3500/3700 |
1024 | * | 1028 | * |
1025 | **************************************************/ | 1029 | **************************************************/ |
1026 | 1030 | ||
1027 | bool Yopy::isYopy ( ) | 1031 | bool Yopy::isYopy ( ) |
1028 | { | 1032 | { |
1029 | QFile f( "/proc/cpuinfo" ); | 1033 | QFile f( "/proc/cpuinfo" ); |
1030 | if ( f. open ( IO_ReadOnly ) ) { | 1034 | if ( f. open ( IO_ReadOnly ) ) { |
1031 | QTextStream ts ( &f ); | 1035 | QTextStream ts ( &f ); |
1032 | QString line; | 1036 | QString line; |
1033 | while( line = ts. readLine ( ) ) { | 1037 | while( line = ts. readLine ( ) ) { |
1034 | if ( line. left ( 8 ) == "Hardware" ) { | 1038 | if ( line. left ( 8 ) == "Hardware" ) { |
1035 | int loc = line. find ( ":" ); | 1039 | int loc = line. find ( ":" ); |
1036 | if ( loc != -1 ) { | 1040 | if ( loc != -1 ) { |
1037 | QString model = | 1041 | QString model = |
1038 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1042 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1039 | return ( model == "Yopy" ); | 1043 | return ( model == "Yopy" ); |
1040 | } | 1044 | } |
1041 | } | 1045 | } |
1042 | } | 1046 | } |
1043 | } | 1047 | } |
1044 | return false; | 1048 | return false; |
1045 | } | 1049 | } |
1046 | 1050 | ||
1047 | void Yopy::init ( ) | 1051 | void Yopy::init ( ) |
1048 | { | 1052 | { |
1049 | d-> m_vendorstr = "G.Mate"; | 1053 | d-> m_vendorstr = "G.Mate"; |
1050 | d-> m_vendor = Vendor_GMate; | 1054 | d-> m_vendor = Vendor_GMate; |
1051 | d-> m_modelstr = "Yopy3700"; | 1055 | d-> m_modelstr = "Yopy3700"; |
1052 | d-> m_model = Model_Yopy_3700; | 1056 | d-> m_model = Model_Yopy_3700; |
1053 | d-> m_rotation = Rot0; | 1057 | d-> m_rotation = Rot0; |
1054 | 1058 | ||
1055 | d-> m_systemstr = "Linupy"; | 1059 | d-> m_systemstr = "Linupy"; |
1056 | d-> m_system = System_Linupy; | 1060 | d-> m_system = System_Linupy; |
1057 | 1061 | ||
1058 | QFile f ( "/etc/issue" ); | 1062 | QFile f ( "/etc/issue" ); |
1059 | if ( f. open ( IO_ReadOnly )) { | 1063 | if ( f. open ( IO_ReadOnly )) { |
1060 | QTextStream ts ( &f ); | 1064 | QTextStream ts ( &f ); |
1061 | ts.readLine(); | 1065 | ts.readLine(); |
1062 | d-> m_sysverstr = ts. readLine ( ); | 1066 | d-> m_sysverstr = ts. readLine ( ); |
1063 | f. close ( ); | 1067 | f. close ( ); |
1064 | } | 1068 | } |
1065 | } | 1069 | } |
1066 | 1070 | ||
1067 | void Yopy::initButtons ( ) | 1071 | void Yopy::initButtons ( ) |
1068 | { | 1072 | { |
1069 | if ( d-> m_buttons ) | 1073 | if ( d-> m_buttons ) |
1070 | return; | 1074 | return; |
1071 | 1075 | ||
1072 | d-> m_buttons = new QValueList <ODeviceButton>; | 1076 | d-> m_buttons = new QValueList <ODeviceButton>; |
1073 | 1077 | ||
1074 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1078 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1075 | 1079 | ||
1076 | yopy_button *ib = yopy_buttons + i; | 1080 | yopy_button *ib = yopy_buttons + i; |
1077 | 1081 | ||
1078 | ODeviceButton b; | 1082 | ODeviceButton b; |
1079 | 1083 | ||
1080 | b. setKeycode ( ib-> code ); | 1084 | b. setKeycode ( ib-> code ); |
1081 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1085 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1082 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1086 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1083 | b. setFactoryPresetPressedAction | 1087 | b. setFactoryPresetPressedAction |
1084 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1088 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1085 | b. setFactoryPresetHeldAction | 1089 | b. setFactoryPresetHeldAction |
1086 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1090 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1087 | 1091 | ||
1088 | d-> m_buttons-> append ( b ); | 1092 | d-> m_buttons-> append ( b ); |
1089 | } | 1093 | } |
1090 | reloadButtonMapping ( ); | 1094 | reloadButtonMapping ( ); |
1091 | 1095 | ||
1092 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1096 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1093 | connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)), | 1097 | connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)), |
1094 | this, SLOT(systemMessage(const QCString&,const QByteArray&))); | 1098 | this, SLOT(systemMessage(const QCString&,const QByteArray&))); |
1095 | } | 1099 | } |
1096 | 1100 | ||
1097 | bool Yopy::suspend() | 1101 | bool Yopy::suspend() |
1098 | { | 1102 | { |
1099 | /* Opie for Yopy does not implement its own power management at the | 1103 | /* Opie for Yopy does not implement its own power management at the |
1100 | moment. The public version runs parallel to X, and relies on the | 1104 | moment. The public version runs parallel to X, and relies on the |
1101 | existing power management features. */ | 1105 | existing power management features. */ |
1102 | return false; | 1106 | return false; |
1103 | } | 1107 | } |
1104 | 1108 | ||
1105 | bool Yopy::setDisplayBrightness(int /*bright*/) | 1109 | bool Yopy::setDisplayBrightness(int /*bright*/) |
1106 | { | 1110 | { |
1107 | /* The code here works, but is disabled as the current version runs | 1111 | /* The code here works, but is disabled as the current version runs |
1108 | parallel to X, and relies on the existing backlight demon. */ | 1112 | parallel to X, and relies on the existing backlight demon. */ |
1109 | #if 0 | 1113 | #if 0 |
1110 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1114 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1111 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1115 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1112 | if (fd >= 0 ) { | 1116 | if (fd >= 0 ) { |
1113 | if (bright) | 1117 | if (bright) |
1114 | ::write(fd, "1\n", 2); | 1118 | ::write(fd, "1\n", 2); |
1115 | else | 1119 | else |
1116 | ::write(fd, "0\n", 2); | 1120 | ::write(fd, "0\n", 2); |
1117 | ::close(fd); | 1121 | ::close(fd); |
1118 | return true; | 1122 | return true; |
1119 | } | 1123 | } |
1120 | } | 1124 | } |
1121 | #endif | 1125 | #endif |
1122 | return false; | 1126 | return false; |
1123 | } | 1127 | } |
1124 | 1128 | ||
1125 | int Yopy::displayBrightnessResolution() const | 1129 | int Yopy::displayBrightnessResolution() const |
1126 | { | 1130 | { |
1127 | return 2; | 1131 | return 2; |
1128 | } | 1132 | } |
1129 | 1133 | ||
1130 | /************************************************** | 1134 | /************************************************** |
1131 | * | 1135 | * |
1132 | * iPAQ | 1136 | * iPAQ |
1133 | * | 1137 | * |
1134 | **************************************************/ | 1138 | **************************************************/ |
1135 | 1139 | ||
1136 | void iPAQ::init ( ) | 1140 | void iPAQ::init ( ) |
1137 | { | 1141 | { |
1138 | d-> m_vendorstr = "HP"; | 1142 | d-> m_vendorstr = "HP"; |
1139 | d-> m_vendor = Vendor_HP; | 1143 | d-> m_vendor = Vendor_HP; |
1140 | 1144 | ||
1141 | QFile f ( "/proc/hal/model" ); | 1145 | QFile f ( "/proc/hal/model" ); |
1142 | 1146 | ||
1143 | if ( f. open ( IO_ReadOnly )) { | 1147 | if ( f. open ( IO_ReadOnly )) { |
1144 | QTextStream ts ( &f ); | 1148 | QTextStream ts ( &f ); |
1145 | 1149 | ||
1146 | d-> m_modelstr = "H" + ts. readLine ( ); | 1150 | d-> m_modelstr = "H" + ts. readLine ( ); |
1147 | 1151 | ||
1148 | if ( d-> m_modelstr == "H3100" ) | 1152 | if ( d-> m_modelstr == "H3100" ) |
1149 | d-> m_model = Model_iPAQ_H31xx; | 1153 | d-> m_model = Model_iPAQ_H31xx; |
1150 | else if ( d-> m_modelstr == "H3600" ) | 1154 | else if ( d-> m_modelstr == "H3600" ) |
1151 | d-> m_model = Model_iPAQ_H36xx; | 1155 | d-> m_model = Model_iPAQ_H36xx; |
1152 | else if ( d-> m_modelstr == "H3700" ) | 1156 | else if ( d-> m_modelstr == "H3700" ) |
1153 | d-> m_model = Model_iPAQ_H37xx; | 1157 | d-> m_model = Model_iPAQ_H37xx; |
1154 | else if ( d-> m_modelstr == "H3800" ) | 1158 | else if ( d-> m_modelstr == "H3800" ) |
1155 | d-> m_model = Model_iPAQ_H38xx; | 1159 | d-> m_model = Model_iPAQ_H38xx; |
1156 | else if ( d-> m_modelstr == "H3900" ) | 1160 | else if ( d-> m_modelstr == "H3900" ) |
1157 | d-> m_model = Model_iPAQ_H39xx; | 1161 | d-> m_model = Model_iPAQ_H39xx; |
1158 | else if ( d-> m_modelstr == "H5400" ) | 1162 | else if ( d-> m_modelstr == "H5400" ) |
1159 | d-> m_model = Model_iPAQ_H5xxx; | 1163 | d-> m_model = Model_iPAQ_H5xxx; |
1160 | else | 1164 | else |
1161 | d-> m_model = Model_Unknown; | 1165 | d-> m_model = Model_Unknown; |
1162 | 1166 | ||
1163 | f. close ( ); | 1167 | f. close ( ); |
1164 | } | 1168 | } |
1165 | 1169 | ||
1166 | switch ( d-> m_model ) { | 1170 | switch ( d-> m_model ) { |
1167 | case Model_iPAQ_H31xx: | 1171 | case Model_iPAQ_H31xx: |
1168 | case Model_iPAQ_H38xx: | 1172 | case Model_iPAQ_H38xx: |
1169 | d-> m_rotation = Rot90; | 1173 | d-> m_rotation = Rot90; |
1170 | break; | 1174 | break; |
1171 | case Model_iPAQ_H36xx: | 1175 | case Model_iPAQ_H36xx: |
1172 | case Model_iPAQ_H37xx: | 1176 | case Model_iPAQ_H37xx: |
1173 | case Model_iPAQ_H39xx: | 1177 | case Model_iPAQ_H39xx: |
1174 | 1178 | ||
1175 | default: | 1179 | default: |
1176 | d-> m_rotation = Rot270; | 1180 | d-> m_rotation = Rot270; |
1177 | break; | 1181 | break; |
1178 | case Model_iPAQ_H5xxx: | 1182 | case Model_iPAQ_H5xxx: |
1179 | d-> m_rotation = Rot0; | 1183 | d-> m_rotation = Rot0; |
1180 | } | 1184 | } |
1181 | 1185 | ||
1182 | f. setName ( "/etc/familiar-version" ); | 1186 | f. setName ( "/etc/familiar-version" ); |
1183 | if ( f. open ( IO_ReadOnly )) { | 1187 | if ( f. open ( IO_ReadOnly )) { |
1184 | d-> m_systemstr = "Familiar"; | 1188 | d-> m_systemstr = "Familiar"; |
1185 | d-> m_system = System_Familiar; | 1189 | d-> m_system = System_Familiar; |
1186 | 1190 | ||
1187 | QTextStream ts ( &f ); | 1191 | QTextStream ts ( &f ); |
1188 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1192 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1189 | 1193 | ||
1190 | f. close ( ); | 1194 | f. close ( ); |
1191 | } else { | 1195 | } else { |
1192 | f. setName ( "/etc/oz_version" ); | 1196 | f. setName ( "/etc/oz_version" ); |
1193 | 1197 | ||
1194 | if ( f. open ( IO_ReadOnly )) { | 1198 | if ( f. open ( IO_ReadOnly )) { |
1195 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1199 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1196 | d-> m_system = System_Familiar; | 1200 | d-> m_system = System_Familiar; |
1197 | 1201 | ||
1198 | QTextStream ts ( &f ); | 1202 | QTextStream ts ( &f ); |
1199 | ts.setDevice ( &f ); | 1203 | ts.setDevice ( &f ); |
1200 | d-> m_sysverstr = ts. readLine ( ); | 1204 | d-> m_sysverstr = ts. readLine ( ); |
1201 | f. close ( ); | 1205 | f. close ( ); |
1202 | } | 1206 | } |
1203 | } | 1207 | } |
1204 | 1208 | ||
1205 | 1209 | ||
1206 | 1210 | ||
1207 | 1211 | ||
1208 | 1212 | ||
1209 | m_leds [0] = m_leds [1] = Led_Off; | 1213 | m_leds [0] = m_leds [1] = Led_Off; |
1210 | 1214 | ||
1211 | m_power_timer = 0; | 1215 | m_power_timer = 0; |
1212 | 1216 | ||
1213 | } | 1217 | } |
1214 | 1218 | ||
1215 | void iPAQ::initButtons ( ) | 1219 | void iPAQ::initButtons ( ) |
1216 | { | 1220 | { |
1217 | if ( d-> m_buttons ) | 1221 | if ( d-> m_buttons ) |
1218 | return; | 1222 | return; |
1219 | 1223 | ||
1220 | if ( isQWS( ) ) | 1224 | if ( isQWS( ) ) |
1221 | QWSServer::setKeyboardFilter ( this ); | 1225 | QWSServer::setKeyboardFilter ( this ); |
1222 | 1226 | ||
1223 | d-> m_buttons = new QValueList <ODeviceButton>; | 1227 | d-> m_buttons = new QValueList <ODeviceButton>; |
1224 | 1228 | ||
1225 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1229 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1226 | i_button *ib = ipaq_buttons + i; | 1230 | i_button *ib = ipaq_buttons + i; |
1227 | ODeviceButton b; | 1231 | ODeviceButton b; |
1228 | 1232 | ||
1229 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1233 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1230 | b. setKeycode ( ib-> code ); | 1234 | b. setKeycode ( ib-> code ); |
1231 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1235 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1232 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1236 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1237 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1234 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1238 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1235 | 1239 | ||
1236 | d-> m_buttons-> append ( b ); | 1240 | d-> m_buttons-> append ( b ); |
1237 | } | 1241 | } |
1238 | } | 1242 | } |
1239 | reloadButtonMapping ( ); | 1243 | reloadButtonMapping ( ); |
1240 | 1244 | ||
1241 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1245 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1242 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 1246 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
1243 | } | 1247 | } |
1244 | 1248 | ||
1245 | 1249 | ||
1246 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1250 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1247 | 1251 | ||
1248 | typedef struct { | 1252 | typedef struct { |
1249 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1253 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1250 | unsigned char TotalTime; /* Units of 5 seconds */ | 1254 | unsigned char TotalTime; /* Units of 5 seconds */ |
1251 | unsigned char OnTime; /* units of 100m/s */ | 1255 | unsigned char OnTime; /* units of 100m/s */ |
1252 | unsigned char OffTime; /* units of 100m/s */ | 1256 | unsigned char OffTime; /* units of 100m/s */ |
1253 | } LED_IN; | 1257 | } LED_IN; |
1254 | 1258 | ||
1255 | typedef struct { | 1259 | typedef struct { |
1256 | unsigned char mode; | 1260 | unsigned char mode; |
1257 | unsigned char pwr; | 1261 | unsigned char pwr; |
1258 | unsigned char brightness; | 1262 | unsigned char brightness; |
1259 | } FLITE_IN; | 1263 | } FLITE_IN; |
1260 | 1264 | ||
1261 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1265 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1262 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1266 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1263 | 1267 | ||
1264 | 1268 | ||
1265 | QValueList <OLed> iPAQ::ledList ( ) const | 1269 | QValueList <OLed> iPAQ::ledList ( ) const |
1266 | { | 1270 | { |
1267 | QValueList <OLed> vl; | 1271 | QValueList <OLed> vl; |
1268 | vl << Led_Power; | 1272 | vl << Led_Power; |
1269 | 1273 | ||
1270 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1274 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1271 | vl << Led_BlueTooth; | 1275 | vl << Led_BlueTooth; |
1272 | return vl; | 1276 | return vl; |
1273 | } | 1277 | } |
1274 | 1278 | ||
1275 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1279 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1276 | { | 1280 | { |
1277 | QValueList <OLedState> vl; | 1281 | QValueList <OLedState> vl; |
1278 | 1282 | ||
1279 | if ( l == Led_Power ) | 1283 | if ( l == Led_Power ) |
1280 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1284 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1281 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1285 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1282 | vl << Led_Off; // << Led_On << ??? | 1286 | vl << Led_Off; // << Led_On << ??? |
1283 | 1287 | ||
1284 | return vl; | 1288 | return vl; |
1285 | } | 1289 | } |
1286 | 1290 | ||
1287 | OLedState iPAQ::ledState ( OLed l ) const | 1291 | OLedState iPAQ::ledState ( OLed l ) const |
1288 | { | 1292 | { |
1289 | switch ( l ) { | 1293 | switch ( l ) { |
1290 | case Led_Power: | 1294 | case Led_Power: |
1291 | return m_leds [0]; | 1295 | return m_leds [0]; |
1292 | case Led_BlueTooth: | 1296 | case Led_BlueTooth: |
1293 | return m_leds [1]; | 1297 | return m_leds [1]; |
1294 | default: | 1298 | default: |
1295 | return Led_Off; | 1299 | return Led_Off; |
1296 | } | 1300 | } |
1297 | } | 1301 | } |
1298 | 1302 | ||
1299 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1303 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1300 | { | 1304 | { |
1301 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1305 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1302 | 1306 | ||
1303 | if ( l == Led_Power ) { | 1307 | if ( l == Led_Power ) { |
1304 | if ( fd >= 0 ) { | 1308 | if ( fd >= 0 ) { |
1305 | LED_IN leds; | 1309 | LED_IN leds; |
1306 | ::memset ( &leds, 0, sizeof( leds )); | 1310 | ::memset ( &leds, 0, sizeof( leds )); |
1307 | leds. TotalTime = 0; | 1311 | leds. TotalTime = 0; |
1308 | leds. OnTime = 0; | 1312 | leds. OnTime = 0; |
1309 | leds. OffTime = 1; | 1313 | leds. OffTime = 1; |
1310 | leds. OffOnBlink = 2; | 1314 | leds. OffOnBlink = 2; |
1311 | 1315 | ||
1312 | switch ( st ) { | 1316 | switch ( st ) { |
1313 | case Led_Off : leds. OffOnBlink = 0; break; | 1317 | case Led_Off : leds. OffOnBlink = 0; break; |
1314 | case Led_On : leds. OffOnBlink = 1; break; | 1318 | case Led_On : leds. OffOnBlink = 1; break; |
1315 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1319 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1316 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1320 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1317 | } | 1321 | } |
1318 | 1322 | ||
1319 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1323 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1320 | m_leds [0] = st; | 1324 | m_leds [0] = st; |
1321 | return true; | 1325 | return true; |
1322 | } | 1326 | } |
1323 | } | 1327 | } |
1324 | } | 1328 | } |
1325 | return false; | 1329 | return false; |
1326 | } | 1330 | } |
1327 | 1331 | ||
1328 | 1332 | ||
1329 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1333 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1330 | { | 1334 | { |
1331 | int newkeycode = keycode; | 1335 | int newkeycode = keycode; |
1332 | 1336 | ||
1333 | switch ( keycode ) { | 1337 | switch ( keycode ) { |
1334 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1338 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1335 | case HardKey_Menu: { | 1339 | case HardKey_Menu: { |
1336 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1340 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1337 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1341 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1338 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1342 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1339 | newkeycode = HardKey_Mail; | 1343 | newkeycode = HardKey_Mail; |
1340 | } | 1344 | } |
1341 | break; | 1345 | break; |
1342 | } | 1346 | } |
1343 | 1347 | ||
1344 | // Rotate cursor keys 180° or 270° | 1348 | // Rotate cursor keys 180° or 270° |
1345 | case Key_Left : | 1349 | case Key_Left : |
1346 | case Key_Right: | 1350 | case Key_Right: |
1347 | case Key_Up : | 1351 | case Key_Up : |
1348 | case Key_Down : { | 1352 | case Key_Down : { |
1349 | 1353 | ||
1350 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1354 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1351 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1355 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1352 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1356 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1353 | } | 1357 | } |
1354 | // Rotate the cursor keys by 270° | 1358 | // Rotate the cursor keys by 270° |
1355 | // keycode - Key_Left = position of the button starting from left clockwise | 1359 | // keycode - Key_Left = position of the button starting from left clockwise |
1356 | // add the rotation to it and modolo. No we've the original offset | 1360 | // add the rotation to it and modolo. No we've the original offset |
1357 | // add the offset to the Key_Left key | 1361 | // add the offset to the Key_Left key |
1358 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 1362 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
1359 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 1363 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
1360 | break; | 1364 | break; |
1361 | } | 1365 | } |
1362 | 1366 | ||
1363 | // map Power Button short/long press to F34/F35 | 1367 | // map Power Button short/long press to F34/F35 |
1364 | case Key_SysReq: { | 1368 | case Key_SysReq: { |
1365 | if ( isPress ) { | 1369 | if ( isPress ) { |
1366 | if ( m_power_timer ) | 1370 | if ( m_power_timer ) |
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp index 763ff65..17e5cb0 100644 --- a/libopie2/opiemm/osoundsystem.cpp +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -1,317 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/osoundsystem.h> | 32 | #include <opie2/osoundsystem.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | #include <errno.h> | 35 | #include <errno.h> |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
39 | #include <sys/types.h> | 39 | #include <sys/types.h> |
40 | #include <sys/soundcard.h> | 40 | #include <sys/soundcard.h> |
41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
42 | 42 | ||
43 | 43 | ||
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::MM; | 45 | using namespace Opie::MM; |
46 | /*====================================================================================== | 46 | /*====================================================================================== |
47 | * OSoundSystem | 47 | * OSoundSystem |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | OSoundSystem* OSoundSystem::_instance = 0; | 50 | OSoundSystem* OSoundSystem::_instance = 0; |
51 | 51 | ||
52 | OSoundSystem::OSoundSystem() | 52 | OSoundSystem::OSoundSystem() |
53 | { | 53 | { |
54 | odebug << "OSoundSystem::OSoundSystem()" << oendl; | 54 | odebug << "OSoundSystem::OSoundSystem()" << oendl; |
55 | synchronize(); | 55 | synchronize(); |
56 | } | 56 | } |
57 | 57 | ||
58 | void OSoundSystem::synchronize() | 58 | void OSoundSystem::synchronize() |
59 | { | 59 | { |
60 | // gather available interfaces by inspecting /dev | 60 | // gather available interfaces by inspecting /dev |
61 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 61 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
62 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 62 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
63 | 63 | ||
64 | _interfaces.clear(); | 64 | _interfaces.clear(); |
65 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); | 65 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); |
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | 69 | ||
70 | QString str; | 70 | QString str; |
71 | QFile f( "/dev/sound" ); | 71 | QFile f( "/dev/sound" ); |
72 | bool hasFile = f.open( IO_ReadOnly ); | 72 | bool hasFile = f.open( IO_ReadOnly ); |
73 | if ( !hasFile ) | 73 | if ( !hasFile ) |
74 | { | 74 | { |
75 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; | 75 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; |
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | QTextStream s( &f ); | 78 | QTextStream s( &f ); |
79 | s.readLine(); | 79 | s.readLine(); |
80 | s.readLine(); | 80 | s.readLine(); |
81 | while ( !s.atEnd() ) | 81 | while ( !s.atEnd() ) |
82 | { | 82 | { |
83 | s >> str; | 83 | s >> str; |
84 | str.truncate( str.find( ':' ) ); | 84 | str.truncate( str.find( ':' ) ); |
85 | odebug << "OSoundSystem: found interface '" << str << "'" << oendl; | 85 | odebug << "OSoundSystem: found interface '" << str << "'" << oendl; |
86 | OAudioInterface* iface; | 86 | OAudioInterface* iface; |
87 | iface = new OAudioInterface( this, (const char*) str ); | 87 | iface = new OAudioInterface( this, (const char*) str ); |
88 | 88 | ||
89 | _interfaces.insert( str, iface ); | 89 | _interfaces.insert( str, iface ); |
90 | s.readLine(); | 90 | s.readLine(); |
91 | } | 91 | } |
92 | */ | 92 | */ |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | int OSoundSystem::count() const | 96 | int OSoundSystem::count() const |
97 | { | 97 | { |
98 | return _interfaces.count(); | 98 | return _interfaces.count(); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | OSoundCard* OSoundSystem::card( const QString& iface ) const | 102 | OSoundCard* OSoundSystem::card( const QString& iface ) const |
103 | { | 103 | { |
104 | return _interfaces[iface]; | 104 | return _interfaces[iface]; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | OSoundSystem* OSoundSystem::instance() | 108 | OSoundSystem* OSoundSystem::instance() |
109 | { | 109 | { |
110 | if ( !_instance ) _instance = new OSoundSystem(); | 110 | if ( !_instance ) _instance = new OSoundSystem(); |
111 | return _instance; | 111 | return _instance; |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | OSoundSystem::CardIterator OSoundSystem::iterator() const | 115 | OSoundSystem::CardIterator OSoundSystem::iterator() const |
116 | { | 116 | { |
117 | return OSoundSystem::CardIterator( _interfaces ); | 117 | return OSoundSystem::CardIterator( _interfaces ); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | /*====================================================================================== | 121 | /*====================================================================================== |
122 | * OSoundCard | 122 | * OSoundCard |
123 | *======================================================================================*/ | 123 | *======================================================================================*/ |
124 | 124 | ||
125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | 125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) |
126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | 126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) |
127 | { | 127 | { |
128 | odebug << "OSoundCard::OSoundCard()" << oendl; | 128 | odebug << "OSoundCard::OSoundCard()" << oendl; |
129 | init(); | 129 | init(); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | OSoundCard::~OSoundCard() | 133 | OSoundCard::~OSoundCard() |
134 | { | 134 | { |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void OSoundCard::init() | 138 | void OSoundCard::init() |
139 | { | 139 | { |
140 | #ifdef QT_QWS_DEVFS | ||
141 | _audio = new OAudioInterface( this, "/dev/sound/dsp" ); | ||
142 | _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); | ||
143 | #else | ||
140 | _audio = new OAudioInterface( this, "/dev/dsp" ); | 144 | _audio = new OAudioInterface( this, "/dev/dsp" ); |
141 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | 145 | _mixer = new OMixerInterface( this, "/dev/mixer" ); |
146 | #endif | ||
142 | } | 147 | } |
143 | 148 | ||
144 | 149 | ||
145 | /*====================================================================================== | 150 | /*====================================================================================== |
146 | * OAudioInterface | 151 | * OAudioInterface |
147 | *======================================================================================*/ | 152 | *======================================================================================*/ |
148 | 153 | ||
149 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | 154 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) |
150 | :QObject( parent, name ), _sfd(0) | 155 | :QObject( parent, name ), _sfd(0) |
151 | { | 156 | { |
152 | odebug << "OAudioInterface::OAudioInterface()" << oendl; | 157 | odebug << "OAudioInterface::OAudioInterface()" << oendl; |
153 | init(); | 158 | init(); |
154 | } | 159 | } |
155 | 160 | ||
156 | 161 | ||
157 | OAudioInterface::~OAudioInterface() | 162 | OAudioInterface::~OAudioInterface() |
158 | { | 163 | { |
159 | } | 164 | } |
160 | 165 | ||
161 | 166 | ||
162 | void OAudioInterface::init() | 167 | void OAudioInterface::init() |
163 | { | 168 | { |
164 | 169 | ||
165 | 170 | ||
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | /*====================================================================================== | 174 | /*====================================================================================== |
170 | * OMixerInterface | 175 | * OMixerInterface |
171 | *======================================================================================*/ | 176 | *======================================================================================*/ |
172 | 177 | ||
173 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | 178 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) |
174 | :QObject( parent, name ) | 179 | :QObject( parent, name ) |
175 | { | 180 | { |
176 | odebug << "OMixerInterface::OMixerInterface()" << oendl; | 181 | odebug << "OMixerInterface::OMixerInterface()" << oendl; |
177 | init(); | 182 | init(); |
178 | } | 183 | } |
179 | 184 | ||
180 | 185 | ||
181 | OMixerInterface::~OMixerInterface() | 186 | OMixerInterface::~OMixerInterface() |
182 | { | 187 | { |
183 | } | 188 | } |
184 | 189 | ||
185 | 190 | ||
186 | void OMixerInterface::init() | 191 | void OMixerInterface::init() |
187 | { | 192 | { |
188 | // open the device | 193 | // open the device |
189 | _fd = ::open( name(), O_RDWR ); | 194 | _fd = ::open( name(), O_RDWR ); |
190 | if ( _fd == -1 ) | 195 | if ( _fd == -1 ) |
191 | { | 196 | { |
192 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; | 197 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; |
193 | return; | 198 | return; |
194 | } | 199 | } |
195 | 200 | ||
196 | // construct the device capabilities | 201 | // construct the device capabilities |
197 | int devmask = 0; | 202 | int devmask = 0; |
198 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) | 203 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) |
199 | { | 204 | { |
200 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); | 205 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); |
201 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); | 206 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); |
202 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); | 207 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); |
203 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); | 208 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); |
204 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); | 209 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); |
205 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); | 210 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); |
206 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); | 211 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); |
207 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); | 212 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); |
208 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); | 213 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); |
209 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); | 214 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); |
210 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); | 215 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); |
211 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); | 216 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); |
212 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); | 217 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); |
213 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); | 218 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); |
214 | //odebug << "devmask available and constructed." << oendl; | 219 | //odebug << "devmask available and constructed." << oendl; |
215 | } | 220 | } |
216 | 221 | ||
217 | devmask = 0; | 222 | devmask = 0; |
218 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) | 223 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) |
219 | { | 224 | { |
220 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); | 225 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); |
221 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); | 226 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); |
222 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); | 227 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); |
223 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); | 228 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); |
224 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); | 229 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); |
225 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); | 230 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); |
226 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); | 231 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); |
227 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); | 232 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); |
228 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); | 233 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); |
229 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); | 234 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); |
230 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); | 235 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); |
231 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); | 236 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); |
232 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); | 237 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); |
233 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); | 238 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); |
234 | //odebug << "recmask available and constructed." << oendl; | 239 | //odebug << "recmask available and constructed." << oendl; |
235 | } | 240 | } |
236 | 241 | ||
237 | /* ChannelIterator it; | 242 | /* ChannelIterator it; |
238 | for ( it = _channels.begin(); it != _channels.end(); ++it ) | 243 | for ( it = _channels.begin(); it != _channels.end(); ++it ) |
239 | { | 244 | { |
240 | odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; | 245 | odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; |
241 | odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; | 246 | odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; |
242 | } | 247 | } |
243 | */ | 248 | */ |
244 | } | 249 | } |
245 | 250 | ||
246 | QStringList OMixerInterface::allChannels() const | 251 | QStringList OMixerInterface::allChannels() const |
247 | { | 252 | { |
248 | ChannelIterator it = _channels.begin(); | 253 | ChannelIterator it = _channels.begin(); |
249 | QStringList channels; | 254 | QStringList channels; |
250 | while ( it != _channels.end() ) | 255 | while ( it != _channels.end() ) |
251 | { | 256 | { |
252 | channels += it.key(); | 257 | channels += it.key(); |
253 | it++; | 258 | it++; |
254 | } | 259 | } |
255 | return channels; | 260 | return channels; |
256 | } | 261 | } |
257 | 262 | ||
258 | 263 | ||
259 | QStringList OMixerInterface::recChannels() const | 264 | QStringList OMixerInterface::recChannels() const |
260 | { | 265 | { |
261 | owarn << "NYI" << oendl; | 266 | owarn << "NYI" << oendl; |
262 | return QStringList(); | 267 | return QStringList(); |
263 | } | 268 | } |
264 | 269 | ||
265 | 270 | ||
266 | QStringList OMixerInterface::playChannels() const | 271 | QStringList OMixerInterface::playChannels() const |
267 | { | 272 | { |
268 | owarn << "NYI" << oendl; | 273 | owarn << "NYI" << oendl; |
269 | return QStringList(); | 274 | return QStringList(); |
270 | } | 275 | } |
271 | 276 | ||
272 | 277 | ||
273 | bool OMixerInterface::hasChannel( const QString& channel ) | 278 | bool OMixerInterface::hasChannel( const QString& channel ) |
274 | { | 279 | { |
275 | return _channels.contains( channel ); | 280 | return _channels.contains( channel ); |
276 | } | 281 | } |
277 | 282 | ||
278 | 283 | ||
279 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) | 284 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) |
280 | { | 285 | { |
281 | int volume = left; | 286 | int volume = left; |
282 | volume |= ( right == -1 ) ? left << 8 : right << 8; | 287 | volume |= ( right == -1 ) ? left << 8 : right << 8; |
283 | 288 | ||
284 | if ( _channels.contains( channel ) ) | 289 | if ( _channels.contains( channel ) ) |
285 | { | 290 | { |
286 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); | 291 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); |
287 | if ( result == -1 ) | 292 | if ( result == -1 ) |
288 | { | 293 | { |
289 | owarn << "Can't set volume: " << strerror( errno ) << oendl; | 294 | owarn << "Can't set volume: " << strerror( errno ) << oendl; |
290 | } | 295 | } |
291 | else | 296 | else |
292 | { | 297 | { |
293 | if ( result & 0xff != left ) | 298 | if ( result & 0xff != left ) |
294 | { | 299 | { |
295 | owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; | 300 | owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; |
296 | } | 301 | } |
297 | } | 302 | } |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ||
301 | 306 | ||
302 | int OMixerInterface::volume( const QString& channel ) const | 307 | int OMixerInterface::volume( const QString& channel ) const |
303 | { | 308 | { |
304 | int volume; | 309 | int volume; |
305 | 310 | ||
306 | if ( _channels.contains( channel ) ) | 311 | if ( _channels.contains( channel ) ) |
307 | { | 312 | { |
308 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) | 313 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) |
309 | { | 314 | { |
310 | owarn << "Can't get volume: " << strerror( errno ) << oendl; | 315 | owarn << "Can't get volume: " << strerror( errno ) << oendl; |
311 | } | 316 | } |
312 | else return volume; | 317 | else return volume; |
313 | } | 318 | } |
314 | return -1; | 319 | return -1; |
315 | } | 320 | } |
316 | 321 | ||
317 | 322 | ||
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c6d9cfd..ca90427 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,1407 +1,1423 @@ | |||
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 | #ifndef Q_OS_MACX | 23 | #ifndef Q_OS_MACX |
24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | 25 | #endif |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qqueue.h> | 27 | #include <qqueue.h> |
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
30 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
31 | #define private public | 31 | #define private public |
32 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #undef private | 34 | #undef private |
35 | #else | 35 | #else |
36 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
37 | #endif | 37 | #endif |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qpalette.h> | 42 | #include <qpalette.h> |
43 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
44 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
50 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
51 | #include <qevent.h> | 51 | #include <qevent.h> |
52 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
55 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
56 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
57 | 57 | ||
58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
59 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
60 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
61 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
62 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
63 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
64 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
65 | #else | 65 | #else |
66 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
67 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
68 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
69 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
70 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
71 | 71 | ||
72 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
73 | #endif | 73 | #endif |
74 | #include "global.h" | 74 | #include "global.h" |
75 | #include "resource.h" | 75 | #include "resource.h" |
76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
77 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
78 | #endif | 78 | #endif |
79 | #include "config.h" | 79 | #include "config.h" |
80 | #include "network.h" | 80 | #include "network.h" |
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
83 | #include "fontdatabase.h" | 83 | #include "fontdatabase.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
87 | #include "applnk.h" | 87 | #include "applnk.h" |
88 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
89 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
90 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
91 | 91 | ||
92 | #include <unistd.h> | 92 | #include <unistd.h> |
93 | #include <sys/file.h> | 93 | #include <sys/file.h> |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
95 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
96 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
97 | #endif | 97 | #endif |
98 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
99 | 99 | ||
100 | #include <backend/rohfeedback.h> | 100 | #include <backend/rohfeedback.h> |
101 | 101 | ||
102 | 102 | ||
103 | static bool useBigPixmaps = 0; | 103 | static bool useBigPixmaps = 0; |
104 | 104 | ||
105 | class HackWidget : public QWidget | 105 | class HackWidget : public QWidget |
106 | { | 106 | { |
107 | public: | 107 | public: |
108 | bool needsOk() | 108 | bool needsOk() |
109 | { return (getWState() & WState_Reserved1 ); } | 109 | { return (getWState() & WState_Reserved1 ); } |
110 | 110 | ||
111 | QRect normalGeometry() | 111 | QRect normalGeometry() |
112 | { return topData()->normalGeometry; }; | 112 | { return topData()->normalGeometry; }; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | class QPEApplicationData | 115 | class QPEApplicationData |
116 | { | 116 | { |
117 | public: | 117 | public: |
118 | QPEApplicationData ( ) : | 118 | QPEApplicationData ( ) : |
119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
121 | keep_running( true ), qcopQok( false ), | 121 | keep_running( true ), qcopQok( false ), |
122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
123 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 123 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
124 | { | 124 | { |
125 | Config cfg( "qpe" ); | 125 | Config cfg( "qpe" ); |
126 | cfg.setGroup( "Appearance" ); | 126 | cfg.setGroup( "Appearance" ); |
127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
132 | #ifdef OPIE_WITHROHFEEDBACK | 132 | #ifdef OPIE_WITHROHFEEDBACK |
133 | RoH = 0; | 133 | RoH = 0; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | int presstimer; | 137 | int presstimer; |
138 | QWidget* presswidget; | 138 | QWidget* presswidget; |
139 | QPoint presspos; | 139 | QPoint presspos; |
140 | #ifdef OPIE_WITHROHFEEDBACK | 140 | #ifdef OPIE_WITHROHFEEDBACK |
141 | Opie::Internal::RoHFeedback *RoH; | 141 | Opie::Internal::RoHFeedback *RoH; |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | bool rightpressed : 1; | 144 | bool rightpressed : 1; |
145 | bool kbgrabbed : 1; | 145 | bool kbgrabbed : 1; |
146 | bool notbusysent : 1; | 146 | bool notbusysent : 1; |
147 | bool preloaded : 1; | 147 | bool preloaded : 1; |
148 | bool forceshow : 1; | 148 | bool forceshow : 1; |
149 | bool nomaximize : 1; | 149 | bool nomaximize : 1; |
150 | bool keep_running : 1; | 150 | bool keep_running : 1; |
151 | bool qcopQok : 1; | 151 | bool qcopQok : 1; |
152 | 152 | ||
153 | QCString fontFamily; | 153 | QCString fontFamily; |
154 | int fontSize; | 154 | int fontSize; |
155 | int smallIconSize; | 155 | int smallIconSize; |
156 | int bigIconSize; | 156 | int bigIconSize; |
157 | 157 | ||
158 | QStringList langs; | 158 | QStringList langs; |
159 | QString appName; | 159 | QString appName; |
160 | struct QCopRec | 160 | struct QCopRec |
161 | { | 161 | { |
162 | QCopRec( const QCString &ch, const QCString &msg, | 162 | QCopRec( const QCString &ch, const QCString &msg, |
163 | const QByteArray &d ) : | 163 | const QByteArray &d ) : |
164 | channel( ch ), message( msg ), data( d ) | 164 | channel( ch ), message( msg ), data( d ) |
165 | { } | 165 | { } |
166 | 166 | ||
167 | QCString channel; | 167 | QCString channel; |
168 | QCString message; | 168 | QCString message; |
169 | QByteArray data; | 169 | QByteArray data; |
170 | }; | 170 | }; |
171 | QWidget* qpe_main_widget; | 171 | QWidget* qpe_main_widget; |
172 | QGuardedPtr<QWidget> lastraised; | 172 | QGuardedPtr<QWidget> lastraised; |
173 | QQueue<QCopRec> qcopq; | 173 | QQueue<QCopRec> qcopq; |
174 | QString styleName; | 174 | QString styleName; |
175 | QString decorationName; | 175 | QString decorationName; |
176 | 176 | ||
177 | void enqueueQCop( const QCString &ch, const QCString &msg, | 177 | void enqueueQCop( const QCString &ch, const QCString &msg, |
178 | const QByteArray &data ) | 178 | const QByteArray &data ) |
179 | { | 179 | { |
180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
181 | } | 181 | } |
182 | void sendQCopQ() | 182 | void sendQCopQ() |
183 | { | 183 | { |
184 | if (!qcopQok ) | 184 | if (!qcopQok ) |
185 | return; | 185 | return; |
186 | 186 | ||
187 | QCopRec * r; | 187 | QCopRec * r; |
188 | 188 | ||
189 | while((r=qcopq.dequeue())) { | 189 | while((r=qcopq.dequeue())) { |
190 | // remove from queue before sending... | 190 | // remove from queue before sending... |
191 | // event loop can come around again before getting | 191 | // event loop can come around again before getting |
192 | // back from sendLocally | 192 | // back from sendLocally |
193 | #ifndef QT_NO_COP | 193 | #ifndef QT_NO_COP |
194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | delete r; | 197 | delete r; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
202 | { | 202 | { |
203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
204 | { | 204 | { |
205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
206 | } | 206 | } |
207 | QPoint p; | 207 | QPoint p; |
208 | QSize s; | 208 | QSize s; |
209 | bool max; | 209 | bool max; |
210 | if ( mw->isVisible() ) { | 210 | if ( mw->isVisible() ) { |
211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
212 | mw->resize(s); | 212 | mw->resize(s); |
213 | mw->move(p); | 213 | mw->move(p); |
214 | } | 214 | } |
215 | mw->raise(); | 215 | mw->raise(); |
216 | } else { | 216 | } else { |
217 | 217 | ||
218 | if ( mw->layout() && mw->inherits("QDialog") ) { | 218 | if ( mw->layout() && mw->inherits("QDialog") ) { |
219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
220 | mw->resize(s); | 220 | mw->resize(s); |
221 | mw->move(p); | 221 | mw->move(p); |
222 | 222 | ||
223 | if ( max && !nomaximize ) { | 223 | if ( max && !nomaximize ) { |
224 | mw->showMaximized(); | 224 | mw->showMaximized(); |
225 | } else { | 225 | } else { |
226 | mw->show(); | 226 | mw->show(); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | qpe_show_dialog((QDialog*)mw,nomaximize); | 229 | qpe_show_dialog((QDialog*)mw,nomaximize); |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
233 | mw->resize(s); | 233 | mw->resize(s); |
234 | mw->move(p); | 234 | mw->move(p); |
235 | } else { //no stored rectangle, make an estimation | 235 | } else { //no stored rectangle, make an estimation |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | if ( max && !nomaximize ) | 244 | if ( max && !nomaximize ) |
245 | mw->showMaximized(); | 245 | mw->showMaximized(); |
246 | else | 246 | else |
247 | mw->show(); | 247 | mw->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 252 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
253 | { | 253 | { |
254 | QSize sh = d->sizeHint(); | 254 | QSize sh = d->sizeHint(); |
255 | int w = QMAX(sh.width(),d->width()); | 255 | int w = QMAX(sh.width(),d->width()); |
256 | int h = QMAX(sh.height(),d->height()); | 256 | int h = QMAX(sh.height(),d->height()); |
257 | 257 | ||
258 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 258 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
259 | nomax = TRUE; | 259 | nomax = TRUE; |
260 | 260 | ||
261 | #ifndef Q_WS_QWS | 261 | #ifndef Q_WS_QWS |
262 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 262 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
263 | #else | 263 | #else |
264 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 264 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
265 | #endif | 265 | #endif |
266 | 266 | ||
267 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 267 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
268 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 268 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
269 | 269 | ||
270 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 270 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
271 | d->showMaximized(); | 271 | d->showMaximized(); |
272 | } else { | 272 | } else { |
273 | // try centering the dialog around its parent | 273 | // try centering the dialog around its parent |
274 | QPoint p(0,0); | 274 | QPoint p(0,0); |
275 | if ( d->parentWidget() ) { | 275 | if ( d->parentWidget() ) { |
276 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 276 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
277 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 277 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
278 | pp.y() + d->parentWidget()->height()/ 2 ); | 278 | pp.y() + d->parentWidget()->height()/ 2 ); |
279 | } else { | 279 | } else { |
280 | p = QPoint( maxX/2, maxY/2 ); | 280 | p = QPoint( maxX/2, maxY/2 ); |
281 | } | 281 | } |
282 | 282 | ||
283 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 283 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
284 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 284 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
285 | 285 | ||
286 | if ( w >= maxX ) { | 286 | if ( w >= maxX ) { |
287 | if ( p.y() < 0 ) | 287 | if ( p.y() < 0 ) |
288 | p.setY(0); | 288 | p.setY(0); |
289 | if ( p.y() + h > maxY ) | 289 | if ( p.y() + h > maxY ) |
290 | p.setY( maxY - h); | 290 | p.setY( maxY - h); |
291 | 291 | ||
292 | d->resize(maxX, h); | 292 | d->resize(maxX, h); |
293 | d->move(0, p.y() ); | 293 | d->move(0, p.y() ); |
294 | } else if ( h >= maxY ) { | 294 | } else if ( h >= maxY ) { |
295 | if ( p.x() < 0 ) | 295 | if ( p.x() < 0 ) |
296 | p.setX(0); | 296 | p.setX(0); |
297 | if ( p.x() + w > maxX ) | 297 | if ( p.x() + w > maxX ) |
298 | p.setX( maxX - w); | 298 | p.setX( maxX - w); |
299 | 299 | ||
300 | d->resize(w, maxY); | 300 | d->resize(w, maxY); |
301 | d->move(p.x(),0); | 301 | d->move(p.x(),0); |
302 | } else { | 302 | } else { |
303 | d->resize(w, h); | 303 | d->resize(w, h); |
304 | } | 304 | } |
305 | 305 | ||
306 | d->show(); | 306 | d->show(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 310 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
311 | { | 311 | { |
312 | maximized = TRUE; | 312 | maximized = TRUE; |
313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
314 | if ( qApp->desktop()->width() <= 350 ) | 314 | if ( qApp->desktop()->width() <= 350 ) |
315 | return FALSE; | 315 | return FALSE; |
316 | 316 | ||
317 | Config cfg( "qpe" ); | 317 | Config cfg( "qpe" ); |
318 | cfg.setGroup("ApplicationPositions"); | 318 | cfg.setGroup("ApplicationPositions"); |
319 | QString str = cfg.readEntry( app, QString::null ); | 319 | QString str = cfg.readEntry( app, QString::null ); |
320 | QStringList l = QStringList::split(",", str); | 320 | QStringList l = QStringList::split(",", str); |
321 | 321 | ||
322 | if ( l.count() == 5) { | 322 | if ( l.count() == 5) { |
323 | p.setX( l[0].toInt() ); | 323 | p.setX( l[0].toInt() ); |
324 | p.setY( l[1].toInt() ); | 324 | p.setY( l[1].toInt() ); |
325 | 325 | ||
326 | s.setWidth( l[2].toInt() ); | 326 | s.setWidth( l[2].toInt() ); |
327 | s.setHeight( l[3].toInt() ); | 327 | s.setHeight( l[3].toInt() ); |
328 | 328 | ||
329 | maximized = l[4].toInt(); | 329 | maximized = l[4].toInt(); |
330 | 330 | ||
331 | return TRUE; | 331 | return TRUE; |
332 | } | 332 | } |
333 | 333 | ||
334 | return FALSE; | 334 | return FALSE; |
335 | } | 335 | } |
336 | 336 | ||
337 | 337 | ||
338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
339 | { | 339 | { |
340 | #ifndef Q_WS_QWS | 340 | #ifndef Q_WS_QWS |
341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
342 | #endif | 342 | #endif |
343 | int maxX = qt_maxWindowRect.width(); | 343 | int maxX = qt_maxWindowRect.width(); |
344 | int maxY = qt_maxWindowRect.height(); | 344 | int maxY = qt_maxWindowRect.height(); |
345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
347 | 347 | ||
348 | // total window size is not allowed to be larger than desktop window size | 348 | // total window size is not allowed to be larger than desktop window size |
349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
350 | return FALSE; | 350 | return FALSE; |
351 | 351 | ||
352 | if ( wWidth > maxX ) { | 352 | if ( wWidth > maxX ) { |
353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
354 | wWidth = maxX; | 354 | wWidth = maxX; |
355 | } | 355 | } |
356 | 356 | ||
357 | if ( wHeight > maxY ) { | 357 | if ( wHeight > maxY ) { |
358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
359 | wHeight = maxY; | 359 | wHeight = maxY; |
360 | } | 360 | } |
361 | 361 | ||
362 | // any smaller than this and the maximize/close/help buttons will be overlapping | 362 | // any smaller than this and the maximize/close/help buttons will be overlapping |
363 | if ( wWidth < 80 || wHeight < 60 ) | 363 | if ( wWidth < 80 || wHeight < 60 ) |
364 | return FALSE; | 364 | return FALSE; |
365 | 365 | ||
366 | if ( p.x() < 0 ) | 366 | if ( p.x() < 0 ) |
367 | p.setX(0); | 367 | p.setX(0); |
368 | if ( p.y() < 0 ) | 368 | if ( p.y() < 0 ) |
369 | p.setY(0); | 369 | p.setY(0); |
370 | 370 | ||
371 | if ( p.x() + wWidth > maxX ) | 371 | if ( p.x() + wWidth > maxX ) |
372 | p.setX( maxX - wWidth ); | 372 | p.setX( maxX - wWidth ); |
373 | if ( p.y() + wHeight > maxY ) | 373 | if ( p.y() + wHeight > maxY ) |
374 | p.setY( maxY - wHeight ); | 374 | p.setY( maxY - wHeight ); |
375 | 375 | ||
376 | return TRUE; | 376 | return TRUE; |
377 | } | 377 | } |
378 | 378 | ||
379 | static void store_widget_rect(QWidget *w, QString &app) | 379 | static void store_widget_rect(QWidget *w, QString &app) |
380 | { | 380 | { |
381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
382 | if ( qApp->desktop()->width() <= 350 ) | 382 | if ( qApp->desktop()->width() <= 350 ) |
383 | return; | 383 | return; |
384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
385 | // get the non-maximized version, so we have to do it the hard way ) | 385 | // get the non-maximized version, so we have to do it the hard way ) |
386 | int offsetX = w->x() - w->geometry().left(); | 386 | int offsetX = w->x() - w->geometry().left(); |
387 | int offsetY = w->y() - w->geometry().top(); | 387 | int offsetY = w->y() - w->geometry().top(); |
388 | 388 | ||
389 | QRect r; | 389 | QRect r; |
390 | if ( w->isMaximized() ) | 390 | if ( w->isMaximized() ) |
391 | r = ( (HackWidget *) w)->normalGeometry(); | 391 | r = ( (HackWidget *) w)->normalGeometry(); |
392 | else | 392 | else |
393 | r = w->geometry(); | 393 | r = w->geometry(); |
394 | 394 | ||
395 | // Stores the window placement as pos(), size() (due to the offset mapping) | 395 | // Stores the window placement as pos(), size() (due to the offset mapping) |
396 | Config cfg( "qpe" ); | 396 | Config cfg( "qpe" ); |
397 | cfg.setGroup("ApplicationPositions"); | 397 | cfg.setGroup("ApplicationPositions"); |
398 | QString s; | 398 | QString s; |
399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
400 | cfg.writeEntry( app, s ); | 400 | cfg.writeEntry( app, s ); |
401 | } | 401 | } |
402 | 402 | ||
403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
404 | { | 404 | { |
405 | /* | 405 | /* |
406 | // This works but disable it for now until it is safe to apply | 406 | // This works but disable it for now until it is safe to apply |
407 | // What is does is scan the .desktop files of all the apps for | 407 | // What is does is scan the .desktop files of all the apps for |
408 | // the applnk that has the corresponding argv[0] as this program | 408 | // the applnk that has the corresponding argv[0] as this program |
409 | // then it uses the name stored in the .desktop file as the caption | 409 | // then it uses the name stored in the .desktop file as the caption |
410 | // for the main widget. This saves duplicating translations for | 410 | // for the main widget. This saves duplicating translations for |
411 | // the app name in the program and in the .desktop files. | 411 | // the app name in the program and in the .desktop files. |
412 | 412 | ||
413 | AppLnkSet apps( appsPath ); | 413 | AppLnkSet apps( appsPath ); |
414 | 414 | ||
415 | QList<AppLnk> appsList = apps.children(); | 415 | QList<AppLnk> appsList = apps.children(); |
416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
417 | if ( (*it)->exec() == appName ) { | 417 | if ( (*it)->exec() == appName ) { |
418 | mw->setCaption( (*it)->name() ); | 418 | mw->setCaption( (*it)->name() ); |
419 | return TRUE; | 419 | return TRUE; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | */ | 422 | */ |
423 | return FALSE; | 423 | return FALSE; |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | void show(QWidget* mw, bool nomax) | 427 | void show(QWidget* mw, bool nomax) |
428 | { | 428 | { |
429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
430 | nomaximize = nomax; | 430 | nomaximize = nomax; |
431 | qpe_main_widget = mw; | 431 | qpe_main_widget = mw; |
432 | qcopQok = TRUE; | 432 | qcopQok = TRUE; |
433 | #ifndef QT_NO_COP | 433 | #ifndef QT_NO_COP |
434 | 434 | ||
435 | sendQCopQ(); | 435 | sendQCopQ(); |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | if ( preloaded ) { | 438 | if ( preloaded ) { |
439 | if (forceshow) | 439 | if (forceshow) |
440 | show_mx(mw, nomax, appName); | 440 | show_mx(mw, nomax, appName); |
441 | } | 441 | } |
442 | else if ( keep_running ) { | 442 | else if ( keep_running ) { |
443 | show_mx(mw, nomax, appName); | 443 | show_mx(mw, nomax, appName); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | void loadTextCodecs() | 447 | void loadTextCodecs() |
448 | { | 448 | { |
449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
450 | #ifdef Q_OS_MACX | 450 | #ifdef Q_OS_MACX |
451 | QDir dir( path, "lib*.dylib" ); | 451 | QDir dir( path, "lib*.dylib" ); |
452 | #else | 452 | #else |
453 | QDir dir( path, "lib*.so" ); | 453 | QDir dir( path, "lib*.so" ); |
454 | #endif | 454 | #endif |
455 | QStringList list; | 455 | QStringList list; |
456 | if ( dir. exists ( )) | 456 | if ( dir. exists ( )) |
457 | list = dir.entryList(); | 457 | list = dir.entryList(); |
458 | QStringList::Iterator it; | 458 | QStringList::Iterator it; |
459 | for ( it = list.begin(); it != list.end(); ++it ) { | 459 | for ( it = list.begin(); it != list.end(); ++it ) { |
460 | TextCodecInterface *iface = 0; | 460 | TextCodecInterface *iface = 0; |
461 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 461 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
463 | QValueList<int> mibs = iface->mibEnums(); | 463 | QValueList<int> mibs = iface->mibEnums(); |
464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
465 | (void)iface->createForMib(*i); | 465 | (void)iface->createForMib(*i); |
466 | // ### it exists now; need to remember if we can delete it | 466 | // ### it exists now; need to remember if we can delete it |
467 | } | 467 | } |
468 | } | 468 | } |
469 | else { | 469 | else { |
470 | lib->unload(); | 470 | lib->unload(); |
471 | delete lib; | 471 | delete lib; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | void loadImageCodecs() | 476 | void loadImageCodecs() |
477 | { | 477 | { |
478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
479 | #ifdef Q_OS_MACX | 479 | #ifdef Q_OS_MACX |
480 | QDir dir( path, "lib*.dylib" ); | 480 | QDir dir( path, "lib*.dylib" ); |
481 | #else | 481 | #else |
482 | QDir dir( path, "lib*.so" ); | 482 | QDir dir( path, "lib*.so" ); |
483 | #endif | 483 | #endif |
484 | QStringList list; | 484 | QStringList list; |
485 | if ( dir. exists ( )) | 485 | if ( dir. exists ( )) |
486 | list = dir.entryList(); | 486 | list = dir.entryList(); |
487 | QStringList::Iterator it; | 487 | QStringList::Iterator it; |
488 | for ( it = list.begin(); it != list.end(); ++it ) { | 488 | for ( it = list.begin(); it != list.end(); ++it ) { |
489 | ImageCodecInterface *iface = 0; | 489 | ImageCodecInterface *iface = 0; |
490 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 490 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
492 | QStringList formats = iface->keys(); | 492 | QStringList formats = iface->keys(); |
493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
494 | (void)iface->installIOHandler(*i); | 494 | (void)iface->installIOHandler(*i); |
495 | // ### it exists now; need to remember if we can delete it | 495 | // ### it exists now; need to remember if we can delete it |
496 | } | 496 | } |
497 | } | 497 | } |
498 | else { | 498 | else { |
499 | lib->unload(); | 499 | lib->unload(); |
500 | delete lib; | 500 | delete lib; |
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | }; | 505 | }; |
506 | 506 | ||
507 | class ResourceMimeFactory : public QMimeSourceFactory | 507 | class ResourceMimeFactory : public QMimeSourceFactory |
508 | { | 508 | { |
509 | public: | 509 | public: |
510 | ResourceMimeFactory() : resImage( 0 ) | 510 | ResourceMimeFactory() : resImage( 0 ) |
511 | { | 511 | { |
512 | setFilePath( Global::helpPath() ); | 512 | setFilePath( Global::helpPath() ); |
513 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 513 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
514 | } | 514 | } |
515 | ~ResourceMimeFactory() { | 515 | ~ResourceMimeFactory() { |
516 | delete resImage; | 516 | delete resImage; |
517 | } | 517 | } |
518 | 518 | ||
519 | const QMimeSource* data( const QString& abs_name ) const | 519 | const QMimeSource* data( const QString& abs_name ) const |
520 | { | 520 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 522 | if ( !r ) { |
523 | int sl = abs_name.length(); | 523 | int sl = abs_name.length(); |
524 | do { | 524 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 525 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 527 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 528 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 529 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 530 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 531 | if ( !img.isNull() ) { |
532 | delete resImage; | 532 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 533 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 534 | r = resImage; |
535 | } | 535 | } |
536 | } | 536 | } |
537 | while ( !r && sl > 0 ); | 537 | while ( !r && sl > 0 ); |
538 | } | 538 | } |
539 | return r; | 539 | return r; |
540 | } | 540 | } |
541 | private: | 541 | private: |
542 | mutable QImageDrag *resImage; | 542 | mutable QImageDrag *resImage; |
543 | }; | 543 | }; |
544 | 544 | ||
545 | static int& hack(int& i) | 545 | static int& hack(int& i) |
546 | { | 546 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 548 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 549 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 550 | (void)new QUtf16Codec; |
551 | #endif | 551 | #endif |
552 | return i; | 552 | return i; |
553 | } | 553 | } |
554 | 554 | ||
555 | static int muted = 0; | 555 | static int muted = 0; |
556 | static int micMuted = 0; | 556 | static int micMuted = 0; |
557 | 557 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 558 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 559 | { |
560 | switch ( t ) { | 560 | switch ( t ) { |
561 | case 0: { | 561 | case 0: { |
562 | Config cfg( "qpe" ); | 562 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 563 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 564 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 566 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 567 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | ||
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
570 | #else | ||
568 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | ||
569 | int vol = muted ? 0 : percent; | 573 | int vol = muted ? 0 : percent; |
570 | // set both channels to same volume | 574 | // set both channels to same volume |
571 | vol |= vol << 8; | 575 | vol |= vol << 8; |
572 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
573 | ::close( fd ); | 577 | ::close( fd ); |
574 | } | 578 | } |
575 | #endif | 579 | #endif |
576 | } | 580 | } |
577 | break; | 581 | break; |
578 | } | 582 | } |
579 | } | 583 | } |
580 | 584 | ||
581 | static void setMic( int t = 0, int percent = -1 ) | 585 | static void setMic( int t = 0, int percent = -1 ) |
582 | { | 586 | { |
583 | switch ( t ) { | 587 | switch ( t ) { |
584 | case 0: { | 588 | case 0: { |
585 | Config cfg( "qpe" ); | 589 | Config cfg( "qpe" ); |
586 | cfg.setGroup( "Volume" ); | 590 | cfg.setGroup( "Volume" ); |
587 | if ( percent < 0 ) | 591 | if ( percent < 0 ) |
588 | percent = cfg.readNumEntry( "Mic", 50 ); | 592 | percent = cfg.readNumEntry( "Mic", 50 ); |
589 | 593 | ||
590 | #ifndef QT_NO_SOUND | 594 | #ifndef QT_NO_SOUND |
591 | int fd = 0; | 595 | int fd = 0; |
592 | int mic = micMuted ? 0 : percent; | 596 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | ||
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
599 | #else | ||
593 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | ||
594 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
595 | ::close( fd ); | 603 | ::close( fd ); |
596 | } | 604 | } |
597 | #endif | 605 | #endif |
598 | } | 606 | } |
599 | break; | 607 | break; |
600 | } | 608 | } |
601 | } | 609 | } |
602 | 610 | ||
603 | 611 | ||
604 | static void setBass( int t = 0, int percent = -1 ) | 612 | static void setBass( int t = 0, int percent = -1 ) |
605 | { | 613 | { |
606 | switch ( t ) { | 614 | switch ( t ) { |
607 | case 0: { | 615 | case 0: { |
608 | Config cfg( "qpe" ); | 616 | Config cfg( "qpe" ); |
609 | cfg.setGroup( "Volume" ); | 617 | cfg.setGroup( "Volume" ); |
610 | if ( percent < 0 ) | 618 | if ( percent < 0 ) |
611 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 619 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
612 | 620 | ||
613 | #ifndef QT_NO_SOUND | 621 | #ifndef QT_NO_SOUND |
614 | int fd = 0; | 622 | int fd = 0; |
615 | int bass = percent; | 623 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | ||
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
626 | #else | ||
616 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | ||
617 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
618 | ::close( fd ); | 630 | ::close( fd ); |
619 | } | 631 | } |
620 | #endif | 632 | #endif |
621 | } | 633 | } |
622 | break; | 634 | break; |
623 | } | 635 | } |
624 | } | 636 | } |
625 | 637 | ||
626 | 638 | ||
627 | static void setTreble( int t = 0, int percent = -1 ) | 639 | static void setTreble( int t = 0, int percent = -1 ) |
628 | { | 640 | { |
629 | switch ( t ) { | 641 | switch ( t ) { |
630 | case 0: { | 642 | case 0: { |
631 | Config cfg( "qpe" ); | 643 | Config cfg( "qpe" ); |
632 | cfg.setGroup( "Volume" ); | 644 | cfg.setGroup( "Volume" ); |
633 | if ( percent < 0 ) | 645 | if ( percent < 0 ) |
634 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
635 | 647 | ||
636 | #ifndef QT_NO_SOUND | 648 | #ifndef QT_NO_SOUND |
637 | int fd = 0; | 649 | int fd = 0; |
638 | int treble = percent; | 650 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | ||
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
653 | #else | ||
639 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | ||
640 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
641 | ::close( fd ); | 657 | ::close( fd ); |
642 | } | 658 | } |
643 | #endif | 659 | #endif |
644 | } | 660 | } |
645 | break; | 661 | break; |
646 | } | 662 | } |
647 | } | 663 | } |
648 | 664 | ||
649 | 665 | ||
650 | /** | 666 | /** |
651 | \class QPEApplication | 667 | \class QPEApplication |
652 | \brief The QPEApplication class implements various system services | 668 | \brief The QPEApplication class implements various system services |
653 | that are available to all Qtopia applications. | 669 | that are available to all Qtopia applications. |
654 | 670 | ||
655 | Simply by using QPEApplication instead of QApplication, a standard Qt | 671 | Simply by using QPEApplication instead of QApplication, a standard Qt |
656 | application becomes a Qtopia application. It automatically follows | 672 | application becomes a Qtopia application. It automatically follows |
657 | style changes, quits and raises, and in the | 673 | style changes, quits and raises, and in the |
658 | case of \link docwidget.html document-oriented\endlink applications, | 674 | case of \link docwidget.html document-oriented\endlink applications, |
659 | changes the currently displayed document in response to the environment. | 675 | changes the currently displayed document in response to the environment. |
660 | 676 | ||
661 | To create a \link docwidget.html document-oriented\endlink | 677 | To create a \link docwidget.html document-oriented\endlink |
662 | application use showMainDocumentWidget(); to create a | 678 | application use showMainDocumentWidget(); to create a |
663 | non-document-oriented application use showMainWidget(). The | 679 | non-document-oriented application use showMainWidget(). The |
664 | keepRunning() function indicates whether the application will | 680 | keepRunning() function indicates whether the application will |
665 | continue running after it's processed the last \link qcop.html | 681 | continue running after it's processed the last \link qcop.html |
666 | QCop\endlink message. This can be changed using setKeepRunning(). | 682 | QCop\endlink message. This can be changed using setKeepRunning(). |
667 | 683 | ||
668 | A variety of signals are emitted when certain events occur, for | 684 | A variety of signals are emitted when certain events occur, for |
669 | example, timeChanged(), clockChanged(), weekChanged(), | 685 | example, timeChanged(), clockChanged(), weekChanged(), |
670 | dateFormatChanged() and volumeChanged(). If the application receives | 686 | dateFormatChanged() and volumeChanged(). If the application receives |
671 | a \link qcop.html QCop\endlink message on the application's | 687 | a \link qcop.html QCop\endlink message on the application's |
672 | QPE/Application/\e{appname} channel, the appMessage() signal is | 688 | QPE/Application/\e{appname} channel, the appMessage() signal is |
673 | emitted. There are also flush() and reload() signals, which | 689 | emitted. There are also flush() and reload() signals, which |
674 | are emitted when synching begins and ends respectively - upon these | 690 | are emitted when synching begins and ends respectively - upon these |
675 | signals, the application should save and reload any data | 691 | signals, the application should save and reload any data |
676 | files that are involved in synching. Most of these signals will initially | 692 | files that are involved in synching. Most of these signals will initially |
677 | be received and unfiltered through the appMessage() signal. | 693 | be received and unfiltered through the appMessage() signal. |
678 | 694 | ||
679 | This class also provides a set of useful static functions. The | 695 | This class also provides a set of useful static functions. The |
680 | qpeDir() and documentDir() functions return the respective paths. | 696 | qpeDir() and documentDir() functions return the respective paths. |
681 | The grabKeyboard() and ungrabKeyboard() functions are used to | 697 | The grabKeyboard() and ungrabKeyboard() functions are used to |
682 | control whether the application takes control of the device's | 698 | control whether the application takes control of the device's |
683 | physical buttons (e.g. application launch keys). The stylus' mode of | 699 | physical buttons (e.g. application launch keys). The stylus' mode of |
684 | operation is set with setStylusOperation() and retrieved with | 700 | operation is set with setStylusOperation() and retrieved with |
685 | stylusOperation(). There are also setInputMethodHint() and | 701 | stylusOperation(). There are also setInputMethodHint() and |
686 | inputMethodHint() functions. | 702 | inputMethodHint() functions. |
687 | 703 | ||
688 | \ingroup qtopiaemb | 704 | \ingroup qtopiaemb |
689 | */ | 705 | */ |
690 | 706 | ||
691 | /*! | 707 | /*! |
692 | \fn void QPEApplication::clientMoused() | 708 | \fn void QPEApplication::clientMoused() |
693 | 709 | ||
694 | \internal | 710 | \internal |
695 | */ | 711 | */ |
696 | 712 | ||
697 | /*! | 713 | /*! |
698 | \fn void QPEApplication::timeChanged(); | 714 | \fn void QPEApplication::timeChanged(); |
699 | This signal is emitted when the time changes outside the normal | 715 | This signal is emitted when the time changes outside the normal |
700 | passage of time, i.e. if the time is set backwards or forwards. | 716 | passage of time, i.e. if the time is set backwards or forwards. |
701 | */ | 717 | */ |
702 | 718 | ||
703 | /*! | 719 | /*! |
704 | \fn void QPEApplication::clockChanged( bool ampm ); | 720 | \fn void QPEApplication::clockChanged( bool ampm ); |
705 | 721 | ||
706 | This signal is emitted when the user changes the clock's style. If | 722 | This signal is emitted when the user changes the clock's style. If |
707 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 723 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
708 | they want a 24-hour clock. | 724 | they want a 24-hour clock. |
709 | */ | 725 | */ |
710 | 726 | ||
711 | /*! | 727 | /*! |
712 | \fn void QPEApplication::volumeChanged( bool muted ) | 728 | \fn void QPEApplication::volumeChanged( bool muted ) |
713 | 729 | ||
714 | This signal is emitted whenever the mute state is changed. If \a | 730 | This signal is emitted whenever the mute state is changed. If \a |
715 | muted is TRUE, then sound output has been muted. | 731 | muted is TRUE, then sound output has been muted. |
716 | */ | 732 | */ |
717 | 733 | ||
718 | /*! | 734 | /*! |
719 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 735 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
720 | 736 | ||
721 | This signal is emitted if the week start day is changed. If \a | 737 | This signal is emitted if the week start day is changed. If \a |
722 | startOnMonday is TRUE then the first day of the week is Monday; if | 738 | startOnMonday is TRUE then the first day of the week is Monday; if |
723 | \a startOnMonday is FALSE then the first day of the week is | 739 | \a startOnMonday is FALSE then the first day of the week is |
724 | Sunday. | 740 | Sunday. |
725 | */ | 741 | */ |
726 | 742 | ||
727 | /*! | 743 | /*! |
728 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 744 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
729 | 745 | ||
730 | This signal is emitted whenever the date format is changed. | 746 | This signal is emitted whenever the date format is changed. |
731 | */ | 747 | */ |
732 | 748 | ||
733 | /*! | 749 | /*! |
734 | \fn void QPEApplication::flush() | 750 | \fn void QPEApplication::flush() |
735 | 751 | ||
736 | ### | 752 | ### |
737 | */ | 753 | */ |
738 | 754 | ||
739 | /*! | 755 | /*! |
740 | \fn void QPEApplication::reload() | 756 | \fn void QPEApplication::reload() |
741 | 757 | ||
742 | */ | 758 | */ |
743 | 759 | ||
744 | 760 | ||
745 | 761 | ||
746 | void QPEApplication::processQCopFile() | 762 | void QPEApplication::processQCopFile() |
747 | { | 763 | { |
748 | QString qcopfn("/tmp/qcop-msg-"); | 764 | QString qcopfn("/tmp/qcop-msg-"); |
749 | qcopfn += d->appName; // append command name | 765 | qcopfn += d->appName; // append command name |
750 | 766 | ||
751 | QFile f(qcopfn); | 767 | QFile f(qcopfn); |
752 | if ( f.open(IO_ReadWrite) ) { | 768 | if ( f.open(IO_ReadWrite) ) { |
753 | #ifndef Q_OS_WIN32 | 769 | #ifndef Q_OS_WIN32 |
754 | flock(f.handle(), LOCK_EX); | 770 | flock(f.handle(), LOCK_EX); |
755 | #endif | 771 | #endif |
756 | QDataStream ds(&f); | 772 | QDataStream ds(&f); |
757 | QCString channel, message; | 773 | QCString channel, message; |
758 | QByteArray data; | 774 | QByteArray data; |
759 | while(!ds.atEnd()) { | 775 | while(!ds.atEnd()) { |
760 | ds >> channel >> message >> data; | 776 | ds >> channel >> message >> data; |
761 | d->enqueueQCop(channel,message,data); | 777 | d->enqueueQCop(channel,message,data); |
762 | } | 778 | } |
763 | ::ftruncate(f.handle(), 0); | 779 | ::ftruncate(f.handle(), 0); |
764 | #ifndef Q_OS_WIN32 | 780 | #ifndef Q_OS_WIN32 |
765 | f.flush(); | 781 | f.flush(); |
766 | flock(f.handle(), LOCK_UN); | 782 | flock(f.handle(), LOCK_UN); |
767 | #endif | 783 | #endif |
768 | } | 784 | } |
769 | #endif | 785 | #endif |
770 | } | 786 | } |
771 | 787 | ||
772 | 788 | ||
773 | /*! | 789 | /*! |
774 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 790 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
775 | 791 | ||
776 | This signal is emitted when a message is received on this | 792 | This signal is emitted when a message is received on this |
777 | application's QPE/Application/<i>appname</i> \link qcop.html | 793 | application's QPE/Application/<i>appname</i> \link qcop.html |
778 | QCop\endlink channel. | 794 | QCop\endlink channel. |
779 | 795 | ||
780 | The slot to which you connect this signal uses \a msg and \a data | 796 | The slot to which you connect this signal uses \a msg and \a data |
781 | in the following way: | 797 | in the following way: |
782 | 798 | ||
783 | \code | 799 | \code |
784 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 800 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
785 | { | 801 | { |
786 | QDataStream stream( data, IO_ReadOnly ); | 802 | QDataStream stream( data, IO_ReadOnly ); |
787 | if ( msg == "someMessage(int,int,int)" ) { | 803 | if ( msg == "someMessage(int,int,int)" ) { |
788 | int a,b,c; | 804 | int a,b,c; |
789 | stream >> a >> b >> c; | 805 | stream >> a >> b >> c; |
790 | ... | 806 | ... |
791 | } else if ( msg == "otherMessage(QString)" ) { | 807 | } else if ( msg == "otherMessage(QString)" ) { |
792 | ... | 808 | ... |
793 | } | 809 | } |
794 | } | 810 | } |
795 | \endcode | 811 | \endcode |
796 | 812 | ||
797 | \sa qcop.html | 813 | \sa qcop.html |
798 | Note that messages received here may be processed by qpe application | 814 | Note that messages received here may be processed by qpe application |
799 | and emitted as signals, such as flush() and reload(). | 815 | and emitted as signals, such as flush() and reload(). |
800 | */ | 816 | */ |
801 | 817 | ||
802 | /*! | 818 | /*! |
803 | Constructs a QPEApplication just as you would construct | 819 | Constructs a QPEApplication just as you would construct |
804 | a QApplication, passing \a argc, \a argv, and \a t. | 820 | a QApplication, passing \a argc, \a argv, and \a t. |
805 | 821 | ||
806 | For applications, \a t should be the default, GuiClient. Only | 822 | For applications, \a t should be the default, GuiClient. Only |
807 | the Qtopia server passes GuiServer. | 823 | the Qtopia server passes GuiServer. |
808 | */ | 824 | */ |
809 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 825 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
810 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 826 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
811 | { | 827 | { |
812 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 828 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
813 | 829 | ||
814 | d = new QPEApplicationData; | 830 | d = new QPEApplicationData; |
815 | d->loadTextCodecs(); | 831 | d->loadTextCodecs(); |
816 | d->loadImageCodecs(); | 832 | d->loadImageCodecs(); |
817 | 833 | ||
818 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 834 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
819 | AppLnk::setSmallIconSize( d->smallIconSize ); | 835 | AppLnk::setSmallIconSize( d->smallIconSize ); |
820 | AppLnk::setBigIconSize( d->bigIconSize ); | 836 | AppLnk::setBigIconSize( d->bigIconSize ); |
821 | 837 | ||
822 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 838 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
823 | 839 | ||
824 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 840 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
825 | 841 | ||
826 | 842 | ||
827 | sysChannel = new QCopChannel( "QPE/System", this ); | 843 | sysChannel = new QCopChannel( "QPE/System", this ); |
828 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 844 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
829 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 845 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
830 | 846 | ||
831 | /* COde now in initapp */ | 847 | /* COde now in initapp */ |
832 | #if 0 | 848 | #if 0 |
833 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 849 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
834 | 850 | ||
835 | QString qcopfn( "/tmp/qcop-msg-" ); | 851 | QString qcopfn( "/tmp/qcop-msg-" ); |
836 | qcopfn += QString( argv[ 0 ] ); // append command name | 852 | qcopfn += QString( argv[ 0 ] ); // append command name |
837 | 853 | ||
838 | QFile f( qcopfn ); | 854 | QFile f( qcopfn ); |
839 | if ( f.open( IO_ReadOnly ) ) { | 855 | if ( f.open( IO_ReadOnly ) ) { |
840 | flock( f.handle(), LOCK_EX ); | 856 | flock( f.handle(), LOCK_EX ); |
841 | } | 857 | } |
842 | 858 | ||
843 | 859 | ||
844 | 860 | ||
845 | QCString channel = QCString( argv[ 0 ] ); | 861 | QCString channel = QCString( argv[ 0 ] ); |
846 | channel.replace( QRegExp( ".*/" ), "" ); | 862 | channel.replace( QRegExp( ".*/" ), "" ); |
847 | d->appName = channel; | 863 | d->appName = channel; |
848 | channel = "QPE/Application/" + channel; | 864 | channel = "QPE/Application/" + channel; |
849 | pidChannel = new QCopChannel( channel, this ); | 865 | pidChannel = new QCopChannel( channel, this ); |
850 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 866 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
851 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 867 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
852 | 868 | ||
853 | if ( f.isOpen() ) { | 869 | if ( f.isOpen() ) { |
854 | d->keep_running = FALSE; | 870 | d->keep_running = FALSE; |
855 | QDataStream ds( &f ); | 871 | QDataStream ds( &f ); |
856 | QCString channel, message; | 872 | QCString channel, message; |
857 | QByteArray data; | 873 | QByteArray data; |
858 | while ( !ds.atEnd() ) { | 874 | while ( !ds.atEnd() ) { |
859 | ds >> channel >> message >> data; | 875 | ds >> channel >> message >> data; |
860 | d->enqueueQCop( channel, message, data ); | 876 | d->enqueueQCop( channel, message, data ); |
861 | } | 877 | } |
862 | 878 | ||
863 | flock( f.handle(), LOCK_UN ); | 879 | flock( f.handle(), LOCK_UN ); |
864 | f.close(); | 880 | f.close(); |
865 | f.remove(); | 881 | f.remove(); |
866 | } | 882 | } |
867 | 883 | ||
868 | for ( int a = 0; a < argc; a++ ) { | 884 | for ( int a = 0; a < argc; a++ ) { |
869 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 885 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
870 | argv[ a ] = argv[ a + 1 ]; | 886 | argv[ a ] = argv[ a + 1 ]; |
871 | a++; | 887 | a++; |
872 | d->preloaded = TRUE; | 888 | d->preloaded = TRUE; |
873 | argc -= 1; | 889 | argc -= 1; |
874 | } | 890 | } |
875 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 891 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
876 | argv[ a ] = argv[ a + 1 ]; | 892 | argv[ a ] = argv[ a + 1 ]; |
877 | a++; | 893 | a++; |
878 | d->preloaded = TRUE; | 894 | d->preloaded = TRUE; |
879 | d->forceshow = TRUE; | 895 | d->forceshow = TRUE; |
880 | argc -= 1; | 896 | argc -= 1; |
881 | } | 897 | } |
882 | } | 898 | } |
883 | 899 | ||
884 | /* overide stored arguments */ | 900 | /* overide stored arguments */ |
885 | setArgs( argc, argv ); | 901 | setArgs( argc, argv ); |
886 | 902 | ||
887 | #endif | 903 | #endif |
888 | #else | 904 | #else |
889 | initApp( argc, argv ); | 905 | initApp( argc, argv ); |
890 | #endif | 906 | #endif |
891 | #ifdef Q_WS_QWS | 907 | #ifdef Q_WS_QWS |
892 | /* load the font renderer factories */ | 908 | /* load the font renderer factories */ |
893 | FontDatabase::loadRenderers(); | 909 | FontDatabase::loadRenderers(); |
894 | #endif | 910 | #endif |
895 | #ifndef QT_NO_TRANSLATION | 911 | #ifndef QT_NO_TRANSLATION |
896 | 912 | ||
897 | d->langs = Global::languageList(); | 913 | d->langs = Global::languageList(); |
898 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 914 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
899 | QString lang = *it; | 915 | QString lang = *it; |
900 | 916 | ||
901 | installTranslation( lang + "/libopie.qm"); | 917 | installTranslation( lang + "/libopie.qm"); |
902 | installTranslation( lang + "/libqpe.qm" ); | 918 | installTranslation( lang + "/libqpe.qm" ); |
903 | installTranslation( lang + "/" + d->appName + ".qm" ); | 919 | installTranslation( lang + "/" + d->appName + ".qm" ); |
904 | 920 | ||
905 | 921 | ||
906 | //###language/font hack; should look it up somewhere | 922 | //###language/font hack; should look it up somewhere |
907 | #ifdef QWS | 923 | #ifdef QWS |
908 | 924 | ||
909 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 925 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
910 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 926 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
911 | setFont( fn ); | 927 | setFont( fn ); |
912 | } | 928 | } |
913 | #endif | 929 | #endif |
914 | } | 930 | } |
915 | #endif | 931 | #endif |
916 | 932 | ||
917 | applyStyle(); | 933 | applyStyle(); |
918 | 934 | ||
919 | if ( type() == GuiServer ) { | 935 | if ( type() == GuiServer ) { |
920 | setVolume(); | 936 | setVolume(); |
921 | } | 937 | } |
922 | 938 | ||
923 | installEventFilter( this ); | 939 | installEventFilter( this ); |
924 | 940 | ||
925 | QPEMenuToolFocusManager::initialize(); | 941 | QPEMenuToolFocusManager::initialize(); |
926 | 942 | ||
927 | #ifdef QT_NO_QWS_CURSOR | 943 | #ifdef QT_NO_QWS_CURSOR |
928 | // if we have no cursor, probably don't want tooltips | 944 | // if we have no cursor, probably don't want tooltips |
929 | QToolTip::setEnabled( FALSE ); | 945 | QToolTip::setEnabled( FALSE ); |
930 | #endif | 946 | #endif |
931 | } | 947 | } |
932 | 948 | ||
933 | 949 | ||
934 | #ifdef QTOPIA_INTERNAL_INITAPP | 950 | #ifdef QTOPIA_INTERNAL_INITAPP |
935 | void QPEApplication::initApp( int argc, char **argv ) | 951 | void QPEApplication::initApp( int argc, char **argv ) |
936 | { | 952 | { |
937 | delete pidChannel; | 953 | delete pidChannel; |
938 | d->keep_running = TRUE; | 954 | d->keep_running = TRUE; |
939 | d->preloaded = FALSE; | 955 | d->preloaded = FALSE; |
940 | d->forceshow = FALSE; | 956 | d->forceshow = FALSE; |
941 | 957 | ||
942 | QCString channel = QCString(argv[0]); | 958 | QCString channel = QCString(argv[0]); |
943 | 959 | ||
944 | channel.replace(QRegExp(".*/"),""); | 960 | channel.replace(QRegExp(".*/"),""); |
945 | d->appName = channel; | 961 | d->appName = channel; |
946 | 962 | ||
947 | #if QT_VERSION > 235 | 963 | #if QT_VERSION > 235 |
948 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 964 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
949 | #endif | 965 | #endif |
950 | 966 | ||
951 | channel = "QPE/Application/" + channel; | 967 | channel = "QPE/Application/" + channel; |
952 | pidChannel = new QCopChannel( channel, this); | 968 | pidChannel = new QCopChannel( channel, this); |
953 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 969 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
954 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 970 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
955 | 971 | ||
956 | 972 | ||
957 | 973 | ||
958 | processQCopFile(); | 974 | processQCopFile(); |
959 | d->keep_running = d->qcopq.isEmpty(); | 975 | d->keep_running = d->qcopq.isEmpty(); |
960 | 976 | ||
961 | for (int a=0; a<argc; a++) { | 977 | for (int a=0; a<argc; a++) { |
962 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 978 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
963 | argv[a] = argv[a+1]; | 979 | argv[a] = argv[a+1]; |
964 | a++; | 980 | a++; |
965 | d->preloaded = TRUE; | 981 | d->preloaded = TRUE; |
966 | argc-=1; | 982 | argc-=1; |
967 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 983 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
968 | argv[a] = argv[a+1]; | 984 | argv[a] = argv[a+1]; |
969 | a++; | 985 | a++; |
970 | d->preloaded = TRUE; | 986 | d->preloaded = TRUE; |
971 | d->forceshow = TRUE; | 987 | d->forceshow = TRUE; |
972 | argc-=1; | 988 | argc-=1; |
973 | } | 989 | } |
974 | } | 990 | } |
975 | 991 | ||
976 | /* overide stored arguments */ | 992 | /* overide stored arguments */ |
977 | setArgs(argc, argv); | 993 | setArgs(argc, argv); |
978 | 994 | ||
979 | /* install translation here */ | 995 | /* install translation here */ |
980 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 996 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
981 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 997 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
982 | } | 998 | } |
983 | #endif | 999 | #endif |
984 | 1000 | ||
985 | 1001 | ||
986 | static QPtrDict<void>* inputMethodDict = 0; | 1002 | static QPtrDict<void>* inputMethodDict = 0; |
987 | static void createInputMethodDict() | 1003 | static void createInputMethodDict() |
988 | { | 1004 | { |
989 | if ( !inputMethodDict ) | 1005 | if ( !inputMethodDict ) |
990 | inputMethodDict = new QPtrDict<void>; | 1006 | inputMethodDict = new QPtrDict<void>; |
991 | } | 1007 | } |
992 | 1008 | ||
993 | /*! | 1009 | /*! |
994 | Returns the currently set hint to the system as to whether | 1010 | Returns the currently set hint to the system as to whether |
995 | widget \a w has any use for text input methods. | 1011 | widget \a w has any use for text input methods. |
996 | 1012 | ||
997 | 1013 | ||
998 | \sa setInputMethodHint() InputMethodHint | 1014 | \sa setInputMethodHint() InputMethodHint |
999 | */ | 1015 | */ |
1000 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 1016 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
1001 | { | 1017 | { |
1002 | if ( inputMethodDict && w ) | 1018 | if ( inputMethodDict && w ) |
1003 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 1019 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
1004 | return Normal; | 1020 | return Normal; |
1005 | } | 1021 | } |
1006 | 1022 | ||
1007 | /*! | 1023 | /*! |
1008 | \enum QPEApplication::InputMethodHint | 1024 | \enum QPEApplication::InputMethodHint |
1009 | 1025 | ||
1010 | \value Normal the application sometimes needs text input (the default). | 1026 | \value Normal the application sometimes needs text input (the default). |
1011 | \value AlwaysOff the application never needs text input. | 1027 | \value AlwaysOff the application never needs text input. |
1012 | \value AlwaysOn the application always needs text input. | 1028 | \value AlwaysOn the application always needs text input. |
1013 | */ | 1029 | */ |
1014 | 1030 | ||
1015 | /*! | 1031 | /*! |
1016 | Hints to the system that widget \a w has use for text input methods | 1032 | Hints to the system that widget \a w has use for text input methods |
1017 | as specified by \a mode. | 1033 | as specified by \a mode. |
1018 | 1034 | ||
1019 | \sa inputMethodHint() InputMethodHint | 1035 | \sa inputMethodHint() InputMethodHint |
1020 | */ | 1036 | */ |
1021 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1037 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1022 | { | 1038 | { |
1023 | createInputMethodDict(); | 1039 | createInputMethodDict(); |
1024 | if ( mode == Normal ) { | 1040 | if ( mode == Normal ) { |
1025 | inputMethodDict->remove | 1041 | inputMethodDict->remove |
1026 | ( w ); | 1042 | ( w ); |
1027 | } | 1043 | } |
1028 | else { | 1044 | else { |
1029 | inputMethodDict->insert( w, ( void* ) mode ); | 1045 | inputMethodDict->insert( w, ( void* ) mode ); |
1030 | } | 1046 | } |
1031 | } | 1047 | } |
1032 | 1048 | ||
1033 | class HackDialog : public QDialog | 1049 | class HackDialog : public QDialog |
1034 | { | 1050 | { |
1035 | public: | 1051 | public: |
1036 | void acceptIt() | 1052 | void acceptIt() |
1037 | { | 1053 | { |
1038 | accept(); | 1054 | accept(); |
1039 | } | 1055 | } |
1040 | void rejectIt() | 1056 | void rejectIt() |
1041 | { | 1057 | { |
1042 | reject(); | 1058 | reject(); |
1043 | } | 1059 | } |
1044 | }; | 1060 | }; |
1045 | 1061 | ||
1046 | 1062 | ||
1047 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1063 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1048 | { | 1064 | { |
1049 | // specialised actions for certain widgets. May want to | 1065 | // specialised actions for certain widgets. May want to |
1050 | // add more stuff here. | 1066 | // add more stuff here. |
1051 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1067 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1052 | && activePopupWidget() ->parentWidget() | 1068 | && activePopupWidget() ->parentWidget() |
1053 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1069 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1054 | key = Qt::Key_Return; | 1070 | key = Qt::Key_Return; |
1055 | 1071 | ||
1056 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1072 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1057 | key = Qt::Key_Return; | 1073 | key = Qt::Key_Return; |
1058 | 1074 | ||
1059 | #ifdef QWS | 1075 | #ifdef QWS |
1060 | 1076 | ||
1061 | ke->simpleData.keycode = key; | 1077 | ke->simpleData.keycode = key; |
1062 | #endif | 1078 | #endif |
1063 | } | 1079 | } |
1064 | 1080 | ||
1065 | 1081 | ||
1066 | /*! | 1082 | /*! |
1067 | \internal | 1083 | \internal |
1068 | */ | 1084 | */ |
1069 | 1085 | ||
1070 | #ifdef QWS | 1086 | #ifdef QWS |
1071 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1087 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1072 | { | 1088 | { |
1073 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1089 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1074 | if ( qApp->type() != QApplication::GuiServer ) { | 1090 | if ( qApp->type() != QApplication::GuiServer ) { |
1075 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1091 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1076 | e << d->appName; | 1092 | e << d->appName; |
1077 | } | 1093 | } |
1078 | d->notbusysent = TRUE; | 1094 | d->notbusysent = TRUE; |
1079 | } | 1095 | } |
1080 | if ( type() == GuiServer ) { | 1096 | if ( type() == GuiServer ) { |
1081 | switch ( e->type ) { | 1097 | switch ( e->type ) { |
1082 | case QWSEvent::Mouse: | 1098 | case QWSEvent::Mouse: |
1083 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1099 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1084 | emit clientMoused(); | 1100 | emit clientMoused(); |
1085 | break; | 1101 | break; |
1086 | default: | 1102 | default: |
1087 | break; | 1103 | break; |
1088 | } | 1104 | } |
1089 | } | 1105 | } |
1090 | if ( e->type == QWSEvent::Key ) { | 1106 | if ( e->type == QWSEvent::Key ) { |
1091 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1107 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1092 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1108 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1093 | // Use special "OK" key to press "OK" on top level widgets | 1109 | // Use special "OK" key to press "OK" on top level widgets |
1094 | QWidget * active = activeWindow(); | 1110 | QWidget * active = activeWindow(); |
1095 | QWidget *popup = 0; | 1111 | QWidget *popup = 0; |
1096 | if ( active && active->isPopup() ) { | 1112 | if ( active && active->isPopup() ) { |
1097 | popup = active; | 1113 | popup = active; |
1098 | active = active->parentWidget(); | 1114 | active = active->parentWidget(); |
1099 | } | 1115 | } |
1100 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1116 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1101 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1117 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1102 | if ( ke->simpleData.is_press ) { | 1118 | if ( ke->simpleData.is_press ) { |
1103 | if ( popup ) | 1119 | if ( popup ) |
1104 | popup->close(); | 1120 | popup->close(); |
1105 | if ( active->inherits( "QDialog" ) ) { | 1121 | if ( active->inherits( "QDialog" ) ) { |
1106 | HackDialog * d = ( HackDialog * ) active; | 1122 | HackDialog * d = ( HackDialog * ) active; |
1107 | d->acceptIt(); | 1123 | d->acceptIt(); |
1108 | return TRUE; | 1124 | return TRUE; |
1109 | } | 1125 | } |
1110 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1126 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1111 | QSignal s; | 1127 | QSignal s; |
1112 | s.connect( active, SLOT( accept() ) ); | 1128 | s.connect( active, SLOT( accept() ) ); |
1113 | s.activate(); | 1129 | s.activate(); |
1114 | } | 1130 | } |
1115 | else { | 1131 | else { |
1116 | // do the same as with the select key: Map to the default action of the widget: | 1132 | // do the same as with the select key: Map to the default action of the widget: |
1117 | mapToDefaultAction( ke, Qt::Key_Return ); | 1133 | mapToDefaultAction( ke, Qt::Key_Return ); |
1118 | } | 1134 | } |
1119 | } | 1135 | } |
1120 | } | 1136 | } |
1121 | } | 1137 | } |
1122 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1138 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1123 | // Use special "select" key to do whatever default action a widget has | 1139 | // Use special "select" key to do whatever default action a widget has |
1124 | mapToDefaultAction( ke, Qt::Key_Space ); | 1140 | mapToDefaultAction( ke, Qt::Key_Space ); |
1125 | } | 1141 | } |
1126 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1142 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1127 | ke->simpleData.is_press ) { | 1143 | ke->simpleData.is_press ) { |
1128 | // Escape key closes app if focus on toplevel | 1144 | // Escape key closes app if focus on toplevel |
1129 | QWidget * active = activeWindow(); | 1145 | QWidget * active = activeWindow(); |
1130 | if ( active && active->testWFlags( WType_TopLevel ) && | 1146 | if ( active && active->testWFlags( WType_TopLevel ) && |
1131 | ( int ) active->winId() == ke->simpleData.window && | 1147 | ( int ) active->winId() == ke->simpleData.window && |
1132 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1148 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1133 | if ( active->inherits( "QDialog" ) ) { | 1149 | if ( active->inherits( "QDialog" ) ) { |
1134 | HackDialog * d = ( HackDialog * ) active; | 1150 | HackDialog * d = ( HackDialog * ) active; |
1135 | d->rejectIt(); | 1151 | d->rejectIt(); |
1136 | return TRUE; | 1152 | return TRUE; |
1137 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1153 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1138 | active->close(); | 1154 | active->close(); |
1139 | } | 1155 | } |
1140 | } | 1156 | } |
1141 | 1157 | ||
1142 | } | 1158 | } |
1143 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1159 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1144 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1160 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1145 | // but we cannot access libopie function within libqpe :( | 1161 | // but we cannot access libopie function within libqpe :( |
1146 | 1162 | ||
1147 | QWidget * active = activeWindow ( ); | 1163 | QWidget * active = activeWindow ( ); |
1148 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1164 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1149 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1165 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1150 | QChar ch ( ke-> simpleData.unicode ); | 1166 | QChar ch ( ke-> simpleData.unicode ); |
1151 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1167 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1152 | ke-> simpleData.keycode, | 1168 | ke-> simpleData.keycode, |
1153 | ch. latin1 ( ), | 1169 | ch. latin1 ( ), |
1154 | ke-> simpleData.modifiers, | 1170 | ke-> simpleData.modifiers, |
1155 | QString ( ch ), | 1171 | QString ( ch ), |
1156 | ke-> simpleData.is_auto_repeat, 1 ); | 1172 | ke-> simpleData.is_auto_repeat, 1 ); |
1157 | 1173 | ||
1158 | QObject *which = QWidget::keyboardGrabber ( ); | 1174 | QObject *which = QWidget::keyboardGrabber ( ); |
1159 | if ( !which ) | 1175 | if ( !which ) |
1160 | which = QApplication::focusWidget ( ); | 1176 | which = QApplication::focusWidget ( ); |
1161 | if ( !which ) | 1177 | if ( !which ) |
1162 | which = QApplication::activeWindow ( ); | 1178 | which = QApplication::activeWindow ( ); |
1163 | if ( !which ) | 1179 | if ( !which ) |
1164 | which = qApp; | 1180 | which = qApp; |
1165 | 1181 | ||
1166 | QApplication::sendEvent ( which, &qke ); | 1182 | QApplication::sendEvent ( which, &qke ); |
1167 | } | 1183 | } |
1168 | else { // we didn't grab the keyboard, so send the event to the launcher | 1184 | else { // we didn't grab the keyboard, so send the event to the launcher |
1169 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1185 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1170 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1186 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1171 | } | 1187 | } |
1172 | } | 1188 | } |
1173 | return true; | 1189 | return true; |
1174 | } | 1190 | } |
1175 | } | 1191 | } |
1176 | if ( e->type == QWSEvent::Focus ) { | 1192 | if ( e->type == QWSEvent::Focus ) { |
1177 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1193 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1178 | if ( !fe->simpleData.get_focus ) { | 1194 | if ( !fe->simpleData.get_focus ) { |
1179 | QWidget * active = activeWindow(); | 1195 | QWidget * active = activeWindow(); |
1180 | while ( active && active->isPopup() ) { | 1196 | while ( active && active->isPopup() ) { |
1181 | active->close(); | 1197 | active->close(); |
1182 | active = activeWindow(); | 1198 | active = activeWindow(); |
1183 | } | 1199 | } |
1184 | } | 1200 | } |
1185 | else { | 1201 | else { |
1186 | // make sure our modal widget is ALWAYS on top | 1202 | // make sure our modal widget is ALWAYS on top |
1187 | QWidget *topm = activeModalWidget(); | 1203 | QWidget *topm = activeModalWidget(); |
1188 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1204 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1189 | topm->raise(); | 1205 | topm->raise(); |
1190 | } | 1206 | } |
1191 | } | 1207 | } |
1192 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1208 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1193 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1209 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1194 | if ( m == AlwaysOff ) | 1210 | if ( m == AlwaysOff ) |
1195 | Global::hideInputMethod(); | 1211 | Global::hideInputMethod(); |
1196 | if ( m == AlwaysOn ) | 1212 | if ( m == AlwaysOn ) |
1197 | Global::showInputMethod(); | 1213 | Global::showInputMethod(); |
1198 | } | 1214 | } |
1199 | } | 1215 | } |
1200 | 1216 | ||
1201 | 1217 | ||
1202 | return QApplication::qwsEventFilter( e ); | 1218 | return QApplication::qwsEventFilter( e ); |
1203 | } | 1219 | } |
1204 | #endif | 1220 | #endif |
1205 | 1221 | ||
1206 | /*! | 1222 | /*! |
1207 | Destroys the QPEApplication. | 1223 | Destroys the QPEApplication. |
1208 | */ | 1224 | */ |
1209 | QPEApplication::~QPEApplication() | 1225 | QPEApplication::~QPEApplication() |
1210 | { | 1226 | { |
1211 | ungrabKeyboard(); | 1227 | ungrabKeyboard(); |
1212 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1228 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1213 | // Need to delete QCopChannels early, since the display will | 1229 | // Need to delete QCopChannels early, since the display will |
1214 | // be gone by the time we get to ~QObject(). | 1230 | // be gone by the time we get to ~QObject(). |
1215 | delete sysChannel; | 1231 | delete sysChannel; |
1216 | delete pidChannel; | 1232 | delete pidChannel; |
1217 | #endif | 1233 | #endif |
1218 | 1234 | ||
1219 | #ifdef OPIE_WITHROHFEEDBACK | 1235 | #ifdef OPIE_WITHROHFEEDBACK |
1220 | if( d->RoH ) | 1236 | if( d->RoH ) |
1221 | delete d->RoH; | 1237 | delete d->RoH; |
1222 | #endif | 1238 | #endif |
1223 | delete d; | 1239 | delete d; |
1224 | } | 1240 | } |
1225 | 1241 | ||
1226 | /*! | 1242 | /*! |
1227 | Returns <tt>$OPIEDIR/</tt>. | 1243 | Returns <tt>$OPIEDIR/</tt>. |
1228 | */ | 1244 | */ |
1229 | QString QPEApplication::qpeDir() | 1245 | QString QPEApplication::qpeDir() |
1230 | { | 1246 | { |
1231 | const char * base = getenv( "OPIEDIR" ); | 1247 | const char * base = getenv( "OPIEDIR" ); |
1232 | if ( base ) | 1248 | if ( base ) |
1233 | return QString( base ) + "/"; | 1249 | return QString( base ) + "/"; |
1234 | 1250 | ||
1235 | return QString( "../" ); | 1251 | return QString( "../" ); |
1236 | } | 1252 | } |
1237 | 1253 | ||
1238 | /*! | 1254 | /*! |
1239 | Returns the user's current Document directory. There is a trailing "/". | 1255 | Returns the user's current Document directory. There is a trailing "/". |
1240 | .. well, it does now,, and there's no trailing '/' | 1256 | .. well, it does now,, and there's no trailing '/' |
1241 | */ | 1257 | */ |
1242 | QString QPEApplication::documentDir() | 1258 | QString QPEApplication::documentDir() |
1243 | { | 1259 | { |
1244 | const char* base = getenv( "HOME"); | 1260 | const char* base = getenv( "HOME"); |
1245 | if ( base ) | 1261 | if ( base ) |
1246 | return QString( base ) + "/Documents"; | 1262 | return QString( base ) + "/Documents"; |
1247 | 1263 | ||
1248 | return QString( "../Documents" ); | 1264 | return QString( "../Documents" ); |
1249 | } | 1265 | } |
1250 | 1266 | ||
1251 | static int deforient = -1; | 1267 | static int deforient = -1; |
1252 | 1268 | ||
1253 | /*! | 1269 | /*! |
1254 | \internal | 1270 | \internal |
1255 | */ | 1271 | */ |
1256 | int QPEApplication::defaultRotation() | 1272 | int QPEApplication::defaultRotation() |
1257 | { | 1273 | { |
1258 | if ( deforient < 0 ) { | 1274 | if ( deforient < 0 ) { |
1259 | QString d = getenv( "QWS_DISPLAY" ); | 1275 | QString d = getenv( "QWS_DISPLAY" ); |
1260 | if ( d.contains( "Rot90" ) ) { | 1276 | if ( d.contains( "Rot90" ) ) { |
1261 | deforient = 90; | 1277 | deforient = 90; |
1262 | } | 1278 | } |
1263 | else if ( d.contains( "Rot180" ) ) { | 1279 | else if ( d.contains( "Rot180" ) ) { |
1264 | deforient = 180; | 1280 | deforient = 180; |
1265 | } | 1281 | } |
1266 | else if ( d.contains( "Rot270" ) ) { | 1282 | else if ( d.contains( "Rot270" ) ) { |
1267 | deforient = 270; | 1283 | deforient = 270; |
1268 | } | 1284 | } |
1269 | else { | 1285 | else { |
1270 | deforient = 0; | 1286 | deforient = 0; |
1271 | } | 1287 | } |
1272 | } | 1288 | } |
1273 | return deforient; | 1289 | return deforient; |
1274 | } | 1290 | } |
1275 | 1291 | ||
1276 | /*! | 1292 | /*! |
1277 | \internal | 1293 | \internal |
1278 | */ | 1294 | */ |
1279 | void QPEApplication::setDefaultRotation( int r ) | 1295 | void QPEApplication::setDefaultRotation( int r ) |
1280 | { | 1296 | { |
1281 | if ( qApp->type() == GuiServer ) { | 1297 | if ( qApp->type() == GuiServer ) { |
1282 | deforient = r; | 1298 | deforient = r; |
1283 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1299 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1284 | Config config("qpe"); | 1300 | Config config("qpe"); |
1285 | config.setGroup( "Rotation" ); | 1301 | config.setGroup( "Rotation" ); |
1286 | config.writeEntry( "Rot", r ); | 1302 | config.writeEntry( "Rot", r ); |
1287 | } | 1303 | } |
1288 | else { | 1304 | else { |
1289 | #ifndef QT_NO_COP | 1305 | #ifndef QT_NO_COP |
1290 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1306 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1291 | e << r; | 1307 | e << r; |
1292 | } | 1308 | } |
1293 | #endif | 1309 | #endif |
1294 | 1310 | ||
1295 | } | 1311 | } |
1296 | } | 1312 | } |
1297 | 1313 | ||
1298 | #include <qgfx_qws.h> | 1314 | #include <qgfx_qws.h> |
1299 | #include <qwindowsystem_qws.h> | 1315 | #include <qwindowsystem_qws.h> |
1300 | 1316 | ||
1301 | #if QT_VERSION > 236 | 1317 | #if QT_VERSION > 236 |
1302 | extern void qws_clearLoadedFonts(); | 1318 | extern void qws_clearLoadedFonts(); |
1303 | #endif | 1319 | #endif |
1304 | 1320 | ||
1305 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1321 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1306 | { | 1322 | { |
1307 | // Reset the caches | 1323 | // Reset the caches |
1308 | #if QT_VERSION > 236 | 1324 | #if QT_VERSION > 236 |
1309 | qws_clearLoadedFonts(); | 1325 | qws_clearLoadedFonts(); |
1310 | #endif | 1326 | #endif |
1311 | QPixmapCache::clear(); | 1327 | QPixmapCache::clear(); |
1312 | 1328 | ||
1313 | // Change the screen mode | 1329 | // Change the screen mode |
1314 | qt_screen->setMode(x, y, depth); | 1330 | qt_screen->setMode(x, y, depth); |
1315 | 1331 | ||
1316 | if ( qApp->type() == GuiServer ) { | 1332 | if ( qApp->type() == GuiServer ) { |
1317 | #if QT_VERSION > 236 | 1333 | #if QT_VERSION > 236 |
1318 | // Reconfigure the GuiServer | 1334 | // Reconfigure the GuiServer |
1319 | qwsServer->beginDisplayReconfigure(); | 1335 | qwsServer->beginDisplayReconfigure(); |
1320 | qwsServer->endDisplayReconfigure(); | 1336 | qwsServer->endDisplayReconfigure(); |
1321 | #endif | 1337 | #endif |
1322 | // Get all the running apps to reset | 1338 | // Get all the running apps to reset |
1323 | QCopEnvelope env( "QPE/System", "reset()" ); | 1339 | QCopEnvelope env( "QPE/System", "reset()" ); |
1324 | } | 1340 | } |
1325 | } | 1341 | } |
1326 | 1342 | ||
1327 | void QPEApplication::reset() { | 1343 | void QPEApplication::reset() { |
1328 | // Reconnect to the screen | 1344 | // Reconnect to the screen |
1329 | qt_screen->disconnect(); | 1345 | qt_screen->disconnect(); |
1330 | qt_screen->connect( QString::null ); | 1346 | qt_screen->connect( QString::null ); |
1331 | 1347 | ||
1332 | // Redraw everything | 1348 | // Redraw everything |
1333 | applyStyle(); | 1349 | applyStyle(); |
1334 | } | 1350 | } |
1335 | 1351 | ||
1336 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1352 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1337 | bool qt_left_hand_scrollbars = false; | 1353 | bool qt_left_hand_scrollbars = false; |
1338 | #else | 1354 | #else |
1339 | #ifdef Q_OS_MACX | 1355 | #ifdef Q_OS_MACX |
1340 | #define WEAK_SYMBOL __attribute__((weak_import)) | 1356 | #define WEAK_SYMBOL __attribute__((weak_import)) |
1341 | #else | 1357 | #else |
1342 | #define WEAK_SYMBOL __attribute__((weak)) | 1358 | #define WEAK_SYMBOL __attribute__((weak)) |
1343 | #endif | 1359 | #endif |
1344 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; | 1360 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; |
1345 | #endif | 1361 | #endif |
1346 | 1362 | ||
1347 | /*! | 1363 | /*! |
1348 | \internal | 1364 | \internal |
1349 | */ | 1365 | */ |
1350 | void QPEApplication::applyStyle() | 1366 | void QPEApplication::applyStyle() |
1351 | { | 1367 | { |
1352 | Config config( "qpe" ); | 1368 | Config config( "qpe" ); |
1353 | config.setGroup( "Appearance" ); | 1369 | config.setGroup( "Appearance" ); |
1354 | 1370 | ||
1355 | #if QT_VERSION > 233 | 1371 | #if QT_VERSION > 233 |
1356 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1372 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1357 | // don't block ourselves ... | 1373 | // don't block ourselves ... |
1358 | Opie::force_appearance = 0; | 1374 | Opie::force_appearance = 0; |
1359 | 1375 | ||
1360 | static QString appname = Opie::binaryName ( ); | 1376 | static QString appname = Opie::binaryName ( ); |
1361 | 1377 | ||
1362 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1378 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1363 | int nostyle = 0; | 1379 | int nostyle = 0; |
1364 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1380 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1365 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1381 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1366 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1382 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1367 | break; | 1383 | break; |
1368 | } | 1384 | } |
1369 | } | 1385 | } |
1370 | #else | 1386 | #else |
1371 | int nostyle = 0; | 1387 | int nostyle = 0; |
1372 | #endif | 1388 | #endif |
1373 | 1389 | ||
1374 | // Widget style | 1390 | // Widget style |
1375 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1391 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1376 | 1392 | ||
1377 | // don't set a custom style | 1393 | // don't set a custom style |
1378 | if ( nostyle & Opie::Force_Style ) | 1394 | if ( nostyle & Opie::Force_Style ) |
1379 | style = "FlatStyle"; | 1395 | style = "FlatStyle"; |
1380 | 1396 | ||
1381 | internalSetStyle ( style ); | 1397 | internalSetStyle ( style ); |
1382 | 1398 | ||
1383 | // Colors - from /etc/colors/Liquid.scheme | 1399 | // Colors - from /etc/colors/Liquid.scheme |
1384 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1400 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1385 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1401 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1386 | QPalette pal( btncolor, bgcolor ); | 1402 | QPalette pal( btncolor, bgcolor ); |
1387 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1403 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1388 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1404 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1389 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1405 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1390 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1406 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1391 | color = config.readEntry( "Text", "#000000" ); | 1407 | color = config.readEntry( "Text", "#000000" ); |
1392 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1408 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1393 | color = config.readEntry( "ButtonText", "#000000" ); | 1409 | color = config.readEntry( "ButtonText", "#000000" ); |
1394 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1410 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1395 | color = config.readEntry( "Base", "#FFFFFF" ); | 1411 | color = config.readEntry( "Base", "#FFFFFF" ); |
1396 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1412 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1397 | 1413 | ||
1398 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1414 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1399 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1415 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1400 | 1416 | ||
1401 | setPalette( pal, TRUE ); | 1417 | setPalette( pal, TRUE ); |
1402 | 1418 | ||
1403 | 1419 | ||
1404 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1420 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1405 | if (&qt_left_hand_scrollbars ) | 1421 | if (&qt_left_hand_scrollbars ) |
1406 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1422 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1407 | 1423 | ||