summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-26 01:14:13 (UTC)
committer llornkcor <llornkcor>2002-07-26 01:14:13 (UTC)
commit630a8f6e4ff5eddaee0089e383c42cc198c68ced (patch) (unidiff)
tree7d743e08c5964eb96f0fb5090d977fdf702c3f44
parentf3678966b4f08e9cc99b5f625c028e6f2d29a8ae (diff)
downloadopie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.zip
opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.gz
opie-630a8f6e4ff5eddaee0089e383c42cc198c68ced.tar.bz2
made 2nd button release stop recording, and fixed umlimited time recording
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp44
-rw-r--r--core/applets/vmemo/vmemo.h2
2 files changed, 27 insertions, 19 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index b5239eb..035965e 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -215,236 +215,240 @@ VMemo::VMemo( QWidget *parent, const char *_name )
215 215
216 t_timer = new QTimer( this ); 216 t_timer = new QTimer( this );
217 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 217 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
218 218
219 struct utsname name; /* check for embedix kernel running on the zaurus*/ 219 struct utsname name; /* check for embedix kernel running on the zaurus*/
220 if (uname(&name) != -1) { 220 if (uname(&name) != -1) {
221 QString release=name.release; 221 QString release=name.release;
222 222
223 Config vmCfg("Vmemo"); 223 Config vmCfg("Vmemo");
224 vmCfg.setGroup("Defaults"); 224 vmCfg.setGroup("Defaults");
225 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 225 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
226 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); 226 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
227 227
228 qDebug("toggleKey %d", toggleKey); 228 qDebug("toggleKey %d", toggleKey);
229 229
230 if(release.find("embedix",0,TRUE) !=-1) 230 if(release.find("embedix",0,TRUE) !=-1)
231 systemZaurus=TRUE; 231 systemZaurus=TRUE;
232 else 232 else
233 systemZaurus=FALSE; 233 systemZaurus=FALSE;
234 234
235 myChannel = new QCopChannel( "QPE/VMemo", this ); 235 myChannel = new QCopChannel( "QPE/VMemo", this );
236 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 236 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
237 this, SLOT(receive(const QCString&, const QByteArray&)) ); 237 this, SLOT(receive(const QCString&, const QByteArray&)) );
238 238
239 if( toggleKey != -1 ) { 239 if( toggleKey != -1 ) {
240 // QPEApplication::grabKeyboard(); 240 // QPEApplication::grabKeyboard();
241 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 241 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
242 // e << 4096; // Key_Escape 242 // e << 4096; // Key_Escape
243 // e << Key_F5; //4148 243 // e << Key_F5; //4148
244 e << toggleKey; 244 e << toggleKey;
245 e << QString("QPE/VMemo"); 245 e << QString("QPE/VMemo");
246 e << QString("toggleRecord()"); 246 e << QString("toggleRecord()");
247 } 247 }
248 if(toggleKey == 1) 248 if(toggleKey == 1)
249 usingIcon=TRUE; 249 usingIcon=TRUE;
250 else 250 else
251 usingIcon=FALSE; 251 usingIcon=FALSE;
252 if( vmCfg.readNumEntry("hideIcon",0) == 1) 252 if( vmCfg.readNumEntry("hideIcon",0) == 1)
253 hide(); 253 hide();
254 } 254 }
255} 255}
256 256
257VMemo::~VMemo() { 257VMemo::~VMemo() {
258} 258}
259 259
260void VMemo::receive( const QCString &msg, const QByteArray &data ) { 260void VMemo::receive( const QCString &msg, const QByteArray &data ) {
261 qDebug("receive"); 261 qDebug("receive");
262 QDataStream stream( data, IO_ReadOnly ); 262 QDataStream stream( data, IO_ReadOnly );
263
263 if (msg == "toggleRecord()") { 264 if (msg == "toggleRecord()") {
264 if (recording) { 265
265 fromToggle = TRUE; 266 if (recording) {
266 mouseReleaseEvent(NULL); 267 fromToggle = TRUE;
267// stopRecording(); 268 mouseReleaseEvent(NULL);
268 } else { 269 stopRecording();
269 fromToggle = TRUE; 270 } else {
270 // mousePressEvent(NULL); 271 fromToggle = TRUE;
271 startRecording(); 272 // mousePressEvent(NULL);
272 } 273 startRecording();
274 }
273 } 275 }
274} 276}
275 277
276void VMemo::paintEvent( QPaintEvent* ) { 278void VMemo::paintEvent( QPaintEvent* ) {
277 QPainter p(this); 279 QPainter p(this);
278 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 280 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
279} 281}
280 282
281void VMemo::mousePressEvent( QMouseEvent * me) { 283void VMemo::mousePressEvent( QMouseEvent * me) {
282 // just to be safe 284 // just to be safe
283 if (recording) { 285 if (recording) {
284 recording = FALSE; 286 recording = FALSE;
285 return; 287 return;
286 } 288 }
287 /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 289 /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
288 mousePressEvent and mouseReleaseEvent with a NULL parameter. */ 290 mousePressEvent and mouseReleaseEvent with a NULL parameter. */
289 if ( me->button() != LeftButton || me != NULL) 291 if ( me->button() != LeftButton || me != NULL)
290 // if (!systemZaurus && me != NULL) 292 // if (!systemZaurus && me != NULL)
291 return; 293 return;
292 294
293 if(!recording) 295 if(!recording)
294 startRecording(); 296 startRecording();
295 else 297 else
296 stopRecording(); 298 stopRecording();
297} 299}
298 300
299void VMemo::mouseReleaseEvent( QMouseEvent * ) { 301void VMemo::mouseReleaseEvent( QMouseEvent * ) {
300// if(usingIcon && !recording) 302// if(usingIcon && !recording)
301// stopRecording(); 303// stopRecording();
302} 304}
303 305
304bool VMemo::startRecording() { 306bool VMemo::startRecording() {
305 307
306 if ( recording) 308 if ( recording)
307 return FALSE; 309 return FALSE;
308 310
309 Config config( "Vmemo" ); 311 Config config( "Vmemo" );
310 config.setGroup( "System" ); 312 config.setGroup( "System" );
311 313
312 useAlerts = config.readBoolEntry("Alert",1); 314 useAlerts = config.readBoolEntry("Alert",1);
313 if(useAlerts) { 315 if(useAlerts) {
314 316
315 msgLabel = new QLabel( 0, "alertLabel" ); 317 msgLabel = new QLabel( 0, "alertLabel" );
316 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 318 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
317 msgLabel->show(); 319 msgLabel->show();
318 } 320 }
319 321
320 // if(useAlerts) 322 // if(useAlerts)
321 // QMessageBox::message("VMemo","Really Record?");//) ==1) 323 // QMessageBox::message("VMemo","Really Record?");//) ==1)
322 // return; 324 // return;
323 // } else { 325 // } else {
324 // if (!systemZaurus ) 326 // if (!systemZaurus )
325 // QSound::play(Resource::findSound("vmemob")); 327 // QSound::play(Resource::findSound("vmemob"));
326 // } 328 // }
327 qDebug("Start recording engines"); 329 qDebug("Start recording engines");
328 recording = TRUE; 330 recording = TRUE;
329 331
330 if (openDSP() == -1) { 332 if (openDSP() == -1) {
331 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 333 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
332 // delete msgLabel; 334 // delete msgLabel;
333 recording = FALSE; 335 recording = FALSE;
334 msgLabel=0; 336 msgLabel=0;
335 delete msgLabel; 337 delete msgLabel;
336 338
337 return FALSE; 339 return FALSE;
338 } 340 }
339 341
340 config.setGroup("Defaults"); 342 config.setGroup("Defaults");
341 343
342 QDateTime dt = QDateTime::currentDateTime(); 344 QDateTime dt = QDateTime::currentDateTime();
343 345
344 QString fName; 346 QString fName;
345 config.setGroup( "System" ); 347 config.setGroup( "System" );
346 fName = QPEApplication::documentDir() ; 348 fName = QPEApplication::documentDir() ;
347 fileName = config.readEntry("RecLocation", fName); 349 fileName = config.readEntry("RecLocation", fName);
348 350
349 int s; 351 int s;
350 s=fileName.find(':'); 352 s=fileName.find(':');
351 if(s) 353 if(s)
352 fileName=fileName.right(fileName.length()-s-2); 354 fileName=fileName.right(fileName.length()-s-2);
353 qDebug("pathname will be "+fileName); 355 qDebug("pathname will be "+fileName);
354 356
355 if( fileName.left(1).find('/') == -1) 357 if( fileName.left(1).find('/') == -1)
356 fileName="/"+fileName; 358 fileName="/"+fileName;
357 if( fileName.right(1).find('/') == -1) 359 if( fileName.right(1).find('/') == -1)
358 fileName+="/"; 360 fileName+="/";
359 fName = "vm_"+ dt.toString()+ ".wav"; 361 fName = "vm_"+ dt.toString()+ ".wav";
360 362
361 fileName+=fName; 363 fileName+=fName;
362 qDebug("filename is "+fileName);
363 // No spaces in the filename 364 // No spaces in the filename
364 fileName.replace(QRegExp("'"),""); 365 fileName.replace(QRegExp("'"),"");
365 fileName.replace(QRegExp(" "),"_"); 366 fileName.replace(QRegExp(" "),"_");
366 fileName.replace(QRegExp(":"),"."); 367 fileName.replace(QRegExp(":"),".");
367 fileName.replace(QRegExp(","),""); 368 fileName.replace(QRegExp(","),"");
368 369
370 qDebug("filename is "+fileName);
369// open tmp file here 371// open tmp file here
370 char *pointer; 372 char *pointer;
371 pointer=tmpnam(NULL); 373 pointer=tmpnam(NULL);
372 qDebug("Opening tmp file %s",pointer); 374 qDebug("Opening tmp file %s",pointer);
373 375
374 if(openWAV(pointer ) == -1) { 376 if(openWAV(pointer ) == -1) {
375 377
376// if(openWAV(fileName.latin1()) == -1) { 378// if(openWAV(fileName.latin1()) == -1) {
377 QString err("Could not open the temp file\n"); 379 QString err("Could not open the temp file\n");
378 err += fileName; 380 err += fileName;
379 QMessageBox::critical(0, "vmemo", err, "Abort"); 381 QMessageBox::critical(0, "vmemo", err, "Abort");
380 ::close(dsp); 382 ::close(dsp);
381 return FALSE; 383 return FALSE;
382 } 384 }
383 record(); 385 if( record() ) {
384 386
385 QString cmd; 387 QString cmd;
386 cmd.sprintf("mv %s "+fileName, pointer); 388 cmd.sprintf("mv %s "+fileName, pointer);
387// move tmp file to regular file here 389// move tmp file to regular file here
388 system(cmd.latin1()); 390 system(cmd.latin1());
389 391
390 QArray<int> cats(1); 392 QArray<int> cats(1);
391 cats[0] = config.readNumEntry("Category", 0); 393 cats[0] = config.readNumEntry("Category", 0);
392 394
393 QString dlName("vm_"); 395 QString dlName("vm_");
394 dlName += dt.toString(); 396 dlName += dt.toString();
395 DocLnk l; 397 DocLnk l;
396 l.setFile(fileName); 398 l.setFile(fileName);
397 l.setName(dlName); 399 l.setName(dlName);
398 l.setType("audio/x-wav"); 400 l.setType("audio/x-wav");
399 l.setCategories(cats); 401 l.setCategories(cats);
400 l.writeLink(); 402 l.writeLink();
401
402 return TRUE; 403 return TRUE;
404 } else
405 return FALSE;
406
403} 407}
404 408
405void VMemo::stopRecording() { 409void VMemo::stopRecording() {
406 show(); 410 show();
407 qDebug("Stopped recording"); 411 qDebug("Stopped recording");
408 recording = FALSE; 412 recording = FALSE;
409 if(useAlerts) { 413 if(useAlerts) {
410 msgLabel->close(); 414 msgLabel->close();
411 msgLabel=0; 415 msgLabel=0;
412 delete msgLabel; 416 delete msgLabel;
413 } 417 }
414 t_timer->stop(); 418 t_timer->stop();
415 Config cfg("Vmemo"); 419 Config cfg("Vmemo");
416 cfg.setGroup("Defaults"); 420 cfg.setGroup("Defaults");
417 if( cfg.readNumEntry("hideIcon",0) == 1 ) 421 if( cfg.readNumEntry("hideIcon",0) == 1 )
418 hide(); 422 hide();
419} 423}
420 424
421int VMemo::openDSP() { 425int VMemo::openDSP() {
422 Config cfg("Vmemo"); 426 Config cfg("Vmemo");
423 cfg.setGroup("Record"); 427 cfg.setGroup("Record");
424 428
425 speed = cfg.readNumEntry("SampleRate", 22050); 429 speed = cfg.readNumEntry("SampleRate", 22050);
426 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 430 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
427 if (cfg.readNumEntry("SixteenBit", 1)==1) { 431 if (cfg.readNumEntry("SixteenBit", 1)==1) {
428 format = AFMT_S16_LE; 432 format = AFMT_S16_LE;
429 resolution = 16; 433 resolution = 16;
430 } else { 434 } else {
431 format = AFMT_U8; 435 format = AFMT_U8;
432 resolution = 8; 436 resolution = 8;
433 } 437 }
434 438
435 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 439 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
436 440
437 if(systemZaurus) { 441 if(systemZaurus) {
438 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 442 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
439 channels=1; //zaurus has one input channel 443 channels=1; //zaurus has one input channel
440 } else { 444 } else {
441 dsp = open("/dev/dsp", O_RDONLY); 445 dsp = open("/dev/dsp", O_RDONLY);
442 } 446 }
443 447
444 if(dsp == -1) { 448 if(dsp == -1) {
445 perror("open(\"/dev/dsp\")"); 449 perror("open(\"/dev/dsp\")");
446 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 450 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
447 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 451 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
448 return -1; 452 return -1;
449 } 453 }
450 454
@@ -459,185 +463,189 @@ int VMemo::openDSP() {
459 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 463 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
460 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 464 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
461 return -1; 465 return -1;
462 } 466 }
463 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 467 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
464 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 468 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
465 return -1; 469 return -1;
466 } 470 }
467 471
468 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute 472 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
469 473
470 return 1; 474 return 1;
471} 475}
472 476
473int VMemo::openWAV(const char *filename) { 477int VMemo::openWAV(const char *filename) {
474 track.setName(filename); 478 track.setName(filename);
475 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 479 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
476 errorMsg=filename; 480 errorMsg=filename;
477 return -1; 481 return -1;
478 } 482 }
479 483
480 wav=track.handle(); 484 wav=track.handle();
481 485
482 WaveHeader wh; 486 WaveHeader wh;
483 487
484 wh.main_chunk = RIFF; 488 wh.main_chunk = RIFF;
485 wh.length=0; 489 wh.length=0;
486 wh.chunk_type = WAVE; 490 wh.chunk_type = WAVE;
487 wh.sub_chunk = FMT; 491 wh.sub_chunk = FMT;
488 wh.sc_len = 16; 492 wh.sc_len = 16;
489 if(useADPCM) 493 if(useADPCM)
490 wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; 494 wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE;
491 else 495 else
492 wh.format = PCM_CODE; 496 wh.format = PCM_CODE;
493 wh.modus = channels; 497 wh.modus = channels;
494 wh.sample_fq = speed; 498 wh.sample_fq = speed;
495 wh.byte_p_sec = speed * channels * resolution/8; 499 wh.byte_p_sec = speed * channels * resolution/8;
496 wh.byte_p_spl = channels * (resolution / 8); 500 wh.byte_p_spl = channels * (resolution / 8);
497 wh.bit_p_spl = resolution; 501 wh.bit_p_spl = resolution;
498 wh.data_chunk = DATA; 502 wh.data_chunk = DATA;
499 wh.data_length= 0; 503 wh.data_length= 0;
500 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" 504 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
501 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); 505 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
502 write (wav, &wh, sizeof(WaveHeader)); 506 write (wav, &wh, sizeof(WaveHeader));
503 507
504 return 1; 508 return 1;
505} 509}
506 510
507void VMemo::record(void) { 511bool VMemo::record() {
508 int length=0, result, value; 512
513 int length=0, result, value;
509 QString msg; 514 QString msg;
510 msg.sprintf("Recording format %d", format); 515 msg.sprintf("Recording format %d", format);
511 qDebug(msg); 516 qDebug(msg);
512 Config config("Vmemo"); 517 Config config("Vmemo");
513 config.setGroup("Record"); 518 config.setGroup("Record");
514 int sRate=config.readNumEntry("SizeLimit", 30); 519 int sRate=config.readNumEntry("SizeLimit", 30);
515 520 if(sRate > 0)
516 t_timer->start( sRate * 1000+1000, TRUE); 521 t_timer->start( sRate * 1000+1000, TRUE);
517 522
518// if(systemZaurus) { 523// if(systemZaurus) {
519// } else { // 16 bit only capabilities 524// } else { // 16 bit only capabilities
520 525
521 msg.sprintf("Recording format other"); 526 msg.sprintf("Recording format other");
522 qDebug(msg); 527 qDebug(msg);
523 528
524 int bufsize=1024; 529 int bufsize=1024;
525 int bytesWritten=0; 530 int bytesWritten=0;
526 signed short sound[1024], monoBuffer[1024]; 531 signed short sound[1024], monoBuffer[1024];
527 char abuf[bufsize/2]; 532 char abuf[bufsize/2];
528 short sbuf[bufsize]; 533 short sbuf[bufsize];
529 534
530 while(recording) { 535 while(recording) {
531 536
532 if(useADPCM) 537 if(useADPCM)
533 result = read( dsp, sbuf, bufsize); // 8192 538 result = read( dsp, sbuf, bufsize); // 8192
534 else 539 else
535 result = read(dsp, sound, 1024); // 8192 540 result = read(dsp, sound, 1024); // 8192
536 if( result <= 0) { 541 if( result <= 0) {
537 perror("recording error "); 542 perror("recording error ");
538// qDebug(currentFileName); 543// qDebug(currentFileName);
539 QMessageBox::message(tr("Note"),tr("error recording")); 544 QMessageBox::message(tr("Note"),tr("error recording"));
540 recording=FALSE;; 545 recording=FALSE;
541 break; 546 break;
547 return FALSE;
542 } 548 }
543 549
544 if(useADPCM) { 550 if(useADPCM) {
545 adpcm_coder( sbuf, abuf, result/2, &encoder_state); 551 adpcm_coder( sbuf, abuf, result/2, &encoder_state);
546 bytesWritten = ::write(wav, abuf, result/4); 552 bytesWritten = ::write(wav, abuf, result/4);
547 553
548 } else { 554 } else {
549 for (int i = 0; i < result; i++) { //since Z is mono do normally 555 for (int i = 0; i < result; i++) { //since Z is mono do normally
550 monoBuffer[i] = sound[i]; 556 monoBuffer[i] = sound[i];
551 } 557 }
552 558
553 length+=write(wav, monoBuffer, result); 559 length+=write(wav, monoBuffer, result);
554 } 560 }
555 length +=bytesWritten; 561 length +=bytesWritten;
556 562
557 if(length<0) { 563 if(length<0) {
558 recording=false; 564 recording=false;
559 perror("dev/dsp's is a lookin' messy"); 565 perror("dev/dsp's is a lookin' messy");
560 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 566 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
567 break;
568 return FALSE;
561 } 569 }
562 // printf("%d\r",length); 570 // printf("%d\r",length);
563 // fflush(stdout); 571 // fflush(stdout);
564 qApp->processEvents(); 572 qApp->processEvents();
565 } 573 }
566 // qDebug("file has length of %d lasting %d seconds", 574 // qDebug("file has length of %d lasting %d seconds",
567 // length, (( length / speed) / channels) / 2 ); 575 // length, (( length / speed) / channels) / 2 );
568 // medialplayer states wrong length in secs 576 // medialplayer states wrong length in secs
569 // } 577 // }
570 578
571 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// 579 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
572 580
573 value = length+36; 581 value = length+36;
574 582
575 lseek(wav, 4, SEEK_SET); 583 lseek(wav, 4, SEEK_SET);
576 write(wav, &value, 4); 584 write(wav, &value, 4);
577 lseek(wav, 40, SEEK_SET); 585 lseek(wav, 40, SEEK_SET);
578 586
579 write(wav, &length, 4); 587 write(wav, &length, 4);
580 588
581 track.close(); 589 track.close();
582 qDebug("Track closed"); 590 qDebug("Track closed");
583 591
584 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 592 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
585 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 593 perror("ioctl(\"SNDCTL_DSP_RESET\")");
586 594
587 ::close(dsp); 595 ::close(dsp);
588 fileName = fileName.left(fileName.length()-4); 596 fileName = fileName.left(fileName.length()-4);
589 // if(useAlerts) 597 // if(useAlerts)
590 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 598 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
591 qDebug("done recording "+fileName); 599 qDebug("done recording "+fileName);
592 600
593// QSound::play(Resource::findSound("vmemoe")); 601// QSound::play(Resource::findSound("vmemoe"));
594 602
595 Config cfg("qpe"); 603 Config cfg("qpe");
596 cfg.setGroup("Volume"); 604 cfg.setGroup("Volume");
597 QString foo = cfg.readEntry("Mute","TRUE"); 605 QString foo = cfg.readEntry("Mute","TRUE");
598 if(foo.find("TRUE",0,TRUE) != -1) 606 if(foo.find("TRUE",0,TRUE) != -1)
599 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute 607 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
600 608return TRUE;
601} 609}
602 610
603int VMemo::setToggleButton(int tog) { 611int VMemo::setToggleButton(int tog) {
604 612
605 for( int i=0; i < 10;i++) { 613 for( int i=0; i < 10;i++) {
606 switch (tog) { 614 switch (tog) {
607 case 0: 615 case 0:
608 return -1; 616 return -1;
609 break; 617 break;
610 case 1: 618 case 1:
611 return 0; 619 return 0;
612 break; 620 break;
613 case 2: 621 case 2:
614 return Key_Escape; 622 return Key_Escape;
615 break; 623 break;
616 case 3: 624 case 3:
617 return Key_Space; 625 return Key_Space;
618 break; 626 break;
619 case 4: 627 case 4:
620 return Key_F12; 628 return Key_F12;
621 break; 629 break;
622 case 5: 630 case 5:
623 return Key_F9; 631 return Key_F9;
624 break; 632 break;
625 case 6: 633 case 6:
626 return Key_F10; 634 return Key_F10;
627 break; 635 break;
628 case 7: 636 case 7:
629 return Key_F11; 637 return Key_F11;
630 break; 638 break;
631 case 8: 639 case 8:
632 return Key_F13; 640 return Key_F13;
633 break; 641 break;
634 }; 642 };
635 } 643 }
636 return -1; 644 return -1;
637} 645}
638 646
639void VMemo::timerBreak() { 647void VMemo::timerBreak() {
640 //stop 648 //stop
641 stopRecording(); 649 stopRecording();
642 QMessageBox::message("Vmemo","Vmemo recording has ended"); 650 QMessageBox::message("Vmemo","Vmemo recording has ended");
643} 651}
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 167af2a..9ee08ff 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -1,63 +1,63 @@
1/**************************************************************************************94x78** 1/**************************************************************************************94x78**
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 12
13/* 13/*
14 * $Id$ 14 * $Id$
15 */ 15 */
16 16
17#ifndef __VMEMO_H__ 17#ifndef __VMEMO_H__
18#define __VMEMO_H__ 18#define __VMEMO_H__
19 19
20 20
21#include <qwidget.h> 21#include <qwidget.h>
22#include <qpixmap.h> 22#include <qpixmap.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qfile.h> 24#include <qfile.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qtimer.h> 27#include <qtimer.h>
28 28
29class VMemo : public QWidget 29class VMemo : public QWidget
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32public: 32public:
33 VMemo( QWidget *parent, const char *name = NULL); 33 VMemo( QWidget *parent, const char *name = NULL);
34 ~VMemo(); 34 ~VMemo();
35 QFile track; 35 QFile track;
36 QString fileName, errorMsg; 36 QString fileName, errorMsg;
37 QLabel* msgLabel; 37 QLabel* msgLabel;
38 QTimer *t_timer; 38 QTimer *t_timer;
39bool usingIcon, useADPCM; 39bool usingIcon, useADPCM;
40public slots: 40public slots:
41 void record(); 41 bool record();
42 void mousePressEvent( QMouseEvent * ); 42 void mousePressEvent( QMouseEvent * );
43 void mouseReleaseEvent( QMouseEvent * ); 43 void mouseReleaseEvent( QMouseEvent * );
44 void receive( const QCString &msg, const QByteArray &data ); 44 void receive( const QCString &msg, const QByteArray &data );
45 bool startRecording(); 45 bool startRecording();
46 void stopRecording(); 46 void stopRecording();
47 void timerBreak(); 47 void timerBreak();
48private: 48private:
49 bool useAlerts; 49 bool useAlerts;
50 void paintEvent( QPaintEvent* ); 50 void paintEvent( QPaintEvent* );
51 int setToggleButton(int); 51 int setToggleButton(int);
52 int openDSP(); 52 int openDSP();
53 int openWAV(const char *filename); 53 int openWAV(const char *filename);
54 bool fromToggle; 54 bool fromToggle;
55 QPixmap vmemoPixmap; 55 QPixmap vmemoPixmap;
56 QCopChannel *myChannel; 56 QCopChannel *myChannel;
57 bool systemZaurus; 57 bool systemZaurus;
58 int dsp, wav, rate, speed, channels, format, resolution; 58 int dsp, wav, rate, speed, channels, format, resolution;
59 bool recording; 59 bool recording;
60}; 60};
61 61
62#endif // __VMEMO_H__ 62#endif // __VMEMO_H__
63 63