summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-05-26 05:03:58 (UTC)
committer llornkcor <llornkcor>2003-05-26 05:03:58 (UTC)
commit410f657febc2951dbe7d10b30294a4529bd6ac0e (patch) (unidiff)
tree2358f965a77dc2801d4b0441000b5a93a58fe6b3
parent57e35a76319a949cb9c065aabf953645b79e7d96 (diff)
downloadopie-410f657febc2951dbe7d10b30294a4529bd6ac0e.zip
opie-410f657febc2951dbe7d10b30294a4529bd6ac0e.tar.gz
opie-410f657febc2951dbe7d10b30294a4529bd6ac0e.tar.bz2
remove extra includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp6
1 files changed, 0 insertions, 6 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 6867e82..7af3d8b 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,337 +1,331 @@
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/* 13/*
14 * $Id$ 14 * $Id$
15 */ 15 */
16// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> 16// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com>
17extern "C" { 17extern "C" {
18#include "adpcm.h" 18#include "adpcm.h"
19} 19}
20 20
21#include <sys/utsname.h> 21#include <sys/utsname.h>
22#include <sys/time.h> 22#include <sys/time.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <sys/stat.h> 26#include <sys/stat.h>
27#include <fcntl.h> 27#include <fcntl.h>
28#include <sys/ioctl.h> 28#include <sys/ioctl.h>
29#include <linux/soundcard.h> 29#include <linux/soundcard.h>
30 30
31#include <string.h> 31#include <string.h>
32#include <stdlib.h> 32#include <stdlib.h>
33#include <errno.h> 33#include <errno.h>
34#include <qtimer.h>
35 34
36typedef struct _waveheader { 35typedef struct _waveheader {
37 u_long main_chunk; /* 'RIFF' */ 36 u_long main_chunk; /* 'RIFF' */
38 u_long length; /* filelen */ 37 u_long length; /* filelen */
39 u_long chunk_type; /* 'WAVE' */ 38 u_long chunk_type; /* 'WAVE' */
40 u_long sub_chunk; /* 'fmt ' */ 39 u_long sub_chunk; /* 'fmt ' */
41 u_long sc_len; /* length of sub_chunk, =16 40 u_long sc_len; /* length of sub_chunk, =16
42 (chunckSize) format len */ 41 (chunckSize) format len */
43 u_short format; /* should be 1 for PCM-code (formatTag) */ 42 u_short format; /* should be 1 for PCM-code (formatTag) */
44 43
45 u_short modus; /* 1 Mono, 2 Stereo (channels) */ 44 u_short modus; /* 1 Mono, 2 Stereo (channels) */
46 u_long sample_fq; /* samples per second (samplesPerSecond) */ 45 u_long sample_fq; /* samples per second (samplesPerSecond) */
47 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ 46 u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */
48 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ 47 u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */
49 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ 48 u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */
50 49
51 u_long data_chunk; /* 'data' */ 50 u_long data_chunk; /* 'data' */
52 51
53 u_long data_length;/* samplecount */ 52 u_long data_length;/* samplecount */
54} WaveHeader; 53} WaveHeader;
55 54
56#define RIFF 0x46464952 55#define RIFF 0x46464952
57#define WAVE 0x45564157 56#define WAVE 0x45564157
58#define FMT 0x20746D66 57#define FMT 0x20746D66
59#define DATA 0x61746164 58#define DATA 0x61746164
60#define PCM_CODE 1 59#define PCM_CODE 1
61#define WAVE_MONO 1 60#define WAVE_MONO 1
62#define WAVE_STEREO 2 61#define WAVE_STEREO 2
63 62
64struct adpcm_state encoder_state; 63struct adpcm_state encoder_state;
65//struct adpcm_state decoder_state; 64//struct adpcm_state decoder_state;
66 65
67#define WAVE_FORMAT_DVI_ADPCM (0x0011) 66#define WAVE_FORMAT_DVI_ADPCM (0x0011)
68#define WAVE_FORMAT_PCM (0x0001) 67#define WAVE_FORMAT_PCM (0x0001)
69 68
70 69
71#include "vmemo.h" 70#include "vmemo.h"
72 71
73#include <qpe/qpeapplication.h> 72#include <qpe/qpeapplication.h>
74#include <qpe/resource.h>
75#include <qpe/config.h> 73#include <qpe/config.h>
76 74
77#include <qpainter.h> 75#include <qpainter.h>
78#include <qdatetime.h>
79#include <qregexp.h>
80#include <qsound.h>
81#include <qfile.h>
82#include <qmessagebox.h> 76#include <qmessagebox.h>
83 77
84int seq = 0; 78int seq = 0;
85 79
86/* XPM */ 80/* XPM */
87static char * vmemo_xpm[] = { 81static char * vmemo_xpm[] = {
88 "16 16 102 2", 82 "16 16 102 2",
89 " c None", 83 " c None",
90 ". c #60636A", 84 ". c #60636A",
91 "+ c #6E6E72", 85 "+ c #6E6E72",
92 "@ c #68696E", 86 "@ c #68696E",
93 "# c #4D525C", 87 "# c #4D525C",
94 "$ c #6B6C70", 88 "$ c #6B6C70",
95 "% c #E3E3E8", 89 "% c #E3E3E8",
96 "& c #EEEEF2", 90 "& c #EEEEF2",
97 "* c #EAEAEF", 91 "* c #EAEAEF",
98 "= c #CACAD0", 92 "= c #CACAD0",
99 "- c #474A51", 93 "- c #474A51",
100 "; c #171819", 94 "; c #171819",
101 "> c #9B9B9F", 95 "> c #9B9B9F",
102 ", c #EBEBF0", 96 ", c #EBEBF0",
103 "' c #F4F4F7", 97 "' c #F4F4F7",
104 ") c #F1F1F5", 98 ") c #F1F1F5",
105 "! c #DEDEE4", 99 "! c #DEDEE4",
106 "~ c #57575C", 100 "~ c #57575C",
107 "{ c #010101", 101 "{ c #010101",
108 "] c #A2A2A6", 102 "] c #A2A2A6",
109 "^ c #747477", 103 "^ c #747477",
110 "/ c #B5B5B8", 104 "/ c #B5B5B8",
111 "( c #AEAEB2", 105 "( c #AEAEB2",
112 "_ c #69696D", 106 "_ c #69696D",
113 ": c #525256", 107 ": c #525256",
114 "< c #181C24", 108 "< c #181C24",
115 "[ c #97979B", 109 "[ c #97979B",
116 "} c #A7A7AC", 110 "} c #A7A7AC",
117 "| c #B0B0B4", 111 "| c #B0B0B4",
118 "1 c #C8C8D1", 112 "1 c #C8C8D1",
119 "2 c #75757B", 113 "2 c #75757B",
120 "3 c #46464A", 114 "3 c #46464A",
121 "4 c #494A4F", 115 "4 c #494A4F",
122 "5 c #323234", 116 "5 c #323234",
123 "6 c #909095", 117 "6 c #909095",
124 "7 c #39393B", 118 "7 c #39393B",
125 "8 c #757578", 119 "8 c #757578",
126 "9 c #87878E", 120 "9 c #87878E",
127 "0 c #222224", 121 "0 c #222224",
128 "a c #414144", 122 "a c #414144",
129 "b c #6A6A6E", 123 "b c #6A6A6E",
130 "c c #020C16", 124 "c c #020C16",
131 "d c #6B6B6F", 125 "d c #6B6B6F",
132 "e c #68686D", 126 "e c #68686D",
133 "f c #5B5B60", 127 "f c #5B5B60",
134 "g c #8A8A8F", 128 "g c #8A8A8F",
135 "h c #6B6B6E", 129 "h c #6B6B6E",
136 "i c #ADADB2", 130 "i c #ADADB2",
137 "j c #828289", 131 "j c #828289",
138 "k c #3E3E41", 132 "k c #3E3E41",
139 "l c #CFCFD7", 133 "l c #CFCFD7",
140 "m c #4C4C50", 134 "m c #4C4C50",
141 "n c #000000", 135 "n c #000000",
142 "o c #66666A", 136 "o c #66666A",
143 "p c #505054", 137 "p c #505054",
144 "q c #838388", 138 "q c #838388",
145 "r c #A1A1A7", 139 "r c #A1A1A7",
146 "s c #A9A9AE", 140 "s c #A9A9AE",
147 "t c #A8A8B0", 141 "t c #A8A8B0",
148 "u c #5E5E63", 142 "u c #5E5E63",
149 "v c #3A3A3E", 143 "v c #3A3A3E",
150 "w c #BDBDC6", 144 "w c #BDBDC6",
151 "x c #59595E", 145 "x c #59595E",
152 "y c #76767C", 146 "y c #76767C",
153 "z c #373738", 147 "z c #373738",
154 "A c #717174", 148 "A c #717174",
155 "B c #727278", 149 "B c #727278",
156 "C c #1C1C1E", 150 "C c #1C1C1E",
157 "D c #3C3C3F", 151 "D c #3C3C3F",
158 "E c #ADADB6", 152 "E c #ADADB6",
159 "F c #54555A", 153 "F c #54555A",
160 "G c #8B8C94", 154 "G c #8B8C94",
161 "H c #5A5A5F", 155 "H c #5A5A5F",
162 "I c #BBBBC3", 156 "I c #BBBBC3",
163 "J c #C4C4CB", 157 "J c #C4C4CB",
164 "K c #909098", 158 "K c #909098",
165 "L c #737379", 159 "L c #737379",
166 "M c #343437", 160 "M c #343437",
167 "N c #8F8F98", 161 "N c #8F8F98",
168 "O c #000407", 162 "O c #000407",
169 "P c #2D3137", 163 "P c #2D3137",
170 "Q c #B0B1BC", 164 "Q c #B0B1BC",
171 "R c #3B3C40", 165 "R c #3B3C40",
172 "S c #6E6E74", 166 "S c #6E6E74",
173 "T c #95959C", 167 "T c #95959C",
174 "U c #74747A", 168 "U c #74747A",
175 "V c #1D1D1E", 169 "V c #1D1D1E",
176 "W c #91929A", 170 "W c #91929A",
177 "X c #42444A", 171 "X c #42444A",
178 "Y c #22282E", 172 "Y c #22282E",
179 "Z c #B0B2BC", 173 "Z c #B0B2BC",
180 "` c #898A90", 174 "` c #898A90",
181 " . c #65656A", 175 " . c #65656A",
182 ".. c #999AA2", 176 ".. c #999AA2",
183 "+. c #52535A", 177 "+. c #52535A",
184 "@. c #151B21", 178 "@. c #151B21",
185 "#. c #515257", 179 "#. c #515257",
186 "$. c #B5B5BE", 180 "$. c #B5B5BE",
187 "%. c #616167", 181 "%. c #616167",
188 "&. c #1A1D22", 182 "&. c #1A1D22",
189 "*. c #000713", 183 "*. c #000713",
190 "=. c #1F1F21", 184 "=. c #1F1F21",
191 " ", 185 " ",
192 " . + @ # ", 186 " . + @ # ",
193 " $ % & * = - ", 187 " $ % & * = - ",
194 " ; > , ' ) ! ~ ", 188 " ; > , ' ) ! ~ ",
195 " { ] ^ / ( _ : ", 189 " { ] ^ / ( _ : ",
196 " < [ } | 1 2 3 ", 190 " < [ } | 1 2 3 ",
197 " 4 5 6 7 8 9 0 a b c ", 191 " 4 5 6 7 8 9 0 a b c ",
198 " d e f g h i j 3 k l m n ", 192 " d e f g h i j 3 k l m n ",
199 " o p q r s t u v w n ", 193 " o p q r s t u v w n ",
200 " o x y z A B C D E n ", 194 " o x y z A B C D E n ",
201 " F G H I J K L M N O ", 195 " F G H I J K L M N O ",
202 " P Q R S T U V W X ", 196 " P Q R S T U V W X ",
203 " Y Z ` b ...+. ", 197 " Y Z ` b ...+. ",
204 " @.#.$.%.&. ", 198 " @.#.$.%.&. ",
205 " *.B =. ", 199 " *.B =. ",
206 " n n n n n n n n n "}; 200 " n n n n n n n n n "};
207 201
208 202
209VMemo::VMemo( QWidget *parent, const char *_name ) 203VMemo::VMemo( QWidget *parent, const char *_name )
210 : QWidget( parent, _name ) { 204 : QWidget( parent, _name ) {
211 setFixedHeight( 18 ); 205 setFixedHeight( 18 );
212 setFixedWidth( 14 ); 206 setFixedWidth( 14 );
213 207
214 t_timer = new QTimer( this ); 208 t_timer = new QTimer( this );
215 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 209 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
216 210
217 struct utsname name; /* check for embedix kernel running on the zaurus*/ 211 struct utsname name; /* check for embedix kernel running on the zaurus*/
218 if (uname(&name) != -1) { 212 if (uname(&name) != -1) {
219 QString release=name.release; 213 QString release=name.release;
220 214
221 Config vmCfg("Vmemo"); 215 Config vmCfg("Vmemo");
222 vmCfg.setGroup("Defaults"); 216 vmCfg.setGroup("Defaults");
223 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 217 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
224 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); 218 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
225 219
226 qDebug("toggleKey %d", toggleKey); 220 qDebug("toggleKey %d", toggleKey);
227 221
228 if(release.find("embedix",0,TRUE) !=-1) 222 if(release.find("embedix",0,TRUE) !=-1)
229 systemZaurus=TRUE; 223 systemZaurus=TRUE;
230 else 224 else
231 systemZaurus=FALSE; 225 systemZaurus=FALSE;
232 226
233 myChannel = new QCopChannel( "QPE/VMemo", this ); 227 myChannel = new QCopChannel( "QPE/VMemo", this );
234 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 228 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
235 this, SLOT(receive(const QCString&, const QByteArray&)) ); 229 this, SLOT(receive(const QCString&, const QByteArray&)) );
236 230
237 if( toggleKey != -1 ) { 231 if( toggleKey != -1 ) {
238 // keyRegister(key, channel, message) 232 // keyRegister(key, channel, message)
239 QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); 233 QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)");
240 // e << 4096; // Key_Escape 234 // e << 4096; // Key_Escape
241 // e << Key_F5; //4148 235 // e << Key_F5; //4148
242 e << toggleKey; 236 e << toggleKey;
243 e << QString("QPE/VMemo"); 237 e << QString("QPE/VMemo");
244 e << QString("toggleRecord()"); 238 e << QString("toggleRecord()");
245 } 239 }
246 if(toggleKey == 1) 240 if(toggleKey == 1)
247 usingIcon=TRUE; 241 usingIcon=TRUE;
248 else 242 else
249 usingIcon=FALSE; 243 usingIcon=FALSE;
250 if( vmCfg.readNumEntry("hideIcon",0) == 1) 244 if( vmCfg.readNumEntry("hideIcon",0) == 1)
251 hide(); 245 hide();
252 recording = FALSE; 246 recording = FALSE;
253 } 247 }
254} 248}
255 249
256VMemo::~VMemo() { 250VMemo::~VMemo() {
257} 251}
258 252
259void VMemo::receive( const QCString &msg, const QByteArray &data ) { 253void VMemo::receive( const QCString &msg, const QByteArray &data ) {
260 qDebug("receive"); 254 qDebug("receive");
261 QDataStream stream( data, IO_ReadOnly ); 255 QDataStream stream( data, IO_ReadOnly );
262 256
263 if (msg == "toggleRecord()") { 257 if (msg == "toggleRecord()") {
264 if (recording) { 258 if (recording) {
265 fromToggle = TRUE; 259 fromToggle = TRUE;
266 stopRecording(); 260 stopRecording();
267 } else { 261 } else {
268 fromToggle = TRUE; 262 fromToggle = TRUE;
269 startRecording(); 263 startRecording();
270 } 264 }
271 } 265 }
272} 266}
273 267
274void VMemo::paintEvent( QPaintEvent* ) { 268void VMemo::paintEvent( QPaintEvent* ) {
275 QPainter p(this); 269 QPainter p(this);
276 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 270 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
277} 271}
278 272
279void VMemo::mousePressEvent( QMouseEvent * me) { 273void VMemo::mousePressEvent( QMouseEvent * me) {
280 /* 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
281 mousePressEvent and mouseReleaseEvent with a NULL parameter. */ 275 mousePressEvent and mouseReleaseEvent with a NULL parameter. */
282 276
283// if (!systemZaurus && me != NULL) 277// if (!systemZaurus && me != NULL)
284// return; 278// return;
285// } 279// }
286 280
287 if(!recording) 281 if(!recording)
288 startRecording(); 282 startRecording();
289 else 283 else
290 stopRecording(); 284 stopRecording();
291} 285}
292 286
293void VMemo::mouseReleaseEvent( QMouseEvent * ) { 287void VMemo::mouseReleaseEvent( QMouseEvent * ) {
294} 288}
295 289
296bool VMemo::startRecording() { 290bool VMemo::startRecording() {
297 Config config( "Vmemo" ); 291 Config config( "Vmemo" );
298 config.setGroup( "System" ); 292 config.setGroup( "System" );
299 293
300 useAlerts = config.readBoolEntry("Alert",1); 294 useAlerts = config.readBoolEntry("Alert",1);
301 if(useAlerts) { 295 if(useAlerts) {
302 296
303 msgLabel = new QLabel( 0, "alertLabel" ); 297 msgLabel = new QLabel( 0, "alertLabel" );
304 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 298 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
305 msgLabel->show(); 299 msgLabel->show();
306 } 300 }
307 301
308 qDebug("Start recording engines"); 302 qDebug("Start recording engines");
309 recording = TRUE; 303 recording = TRUE;
310 304
311 if (openDSP() == -1) { 305 if (openDSP() == -1) {
312 recording = FALSE; 306 recording = FALSE;
313 return FALSE; 307 return FALSE;
314 } 308 }
315 309
316 config.setGroup("Defaults"); 310 config.setGroup("Defaults");
317 311
318 QDateTime dt = QDateTime::currentDateTime(); 312 QDateTime dt = QDateTime::currentDateTime();
319 313
320 QString fName; 314 QString fName;
321 config.setGroup( "System" ); 315 config.setGroup( "System" );
322 fName = QPEApplication::documentDir() ; 316 fName = QPEApplication::documentDir() ;
323 fileName = config.readEntry("RecLocation", fName); 317 fileName = config.readEntry("RecLocation", fName);
324 318
325 int s; 319 int s;
326 s=fileName.find(':'); 320 s=fileName.find(':');
327 if(s) 321 if(s)
328 fileName=fileName.right(fileName.length()-s-2); 322 fileName=fileName.right(fileName.length()-s-2);
329 qDebug("pathname will be "+fileName); 323 qDebug("pathname will be "+fileName);
330 324
331 if( fileName.left(1).find('/') == -1) 325 if( fileName.left(1).find('/') == -1)
332 fileName="/"+fileName; 326 fileName="/"+fileName;
333 if( fileName.right(1).find('/') == -1) 327 if( fileName.right(1).find('/') == -1)
334 fileName+="/"; 328 fileName+="/";
335 fName = "vm_"+ dt.toString()+ ".wav"; 329 fName = "vm_"+ dt.toString()+ ".wav";
336 330
337 fileName+=fName; 331 fileName+=fName;