summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp111
1 files changed, 51 insertions, 60 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index d5808b7..8ba1eb7 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -211,14 +211,10 @@ VMemo::VMemo( QWidget *parent, const char *_name )
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 owarn <<"VMemo toggleKey" << toggleKey << oendl;
215 215
216// if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 216 systemZaurus = false;
217// systemZaurus=TRUE;
218// else
219 systemZaurus = FALSE;
220 217
221// myChannel = new QCopChannel( "QPE/VMemo", this );
222 myChannel = new QCopChannel( "QPE/VMemo", this ); 218 myChannel = new QCopChannel( "QPE/VMemo", this );
223 219
224 connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), 220 connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)),
@@ -226,7 +222,8 @@ VMemo::VMemo( QWidget *parent, const char *_name )
226 222
227 223
228 if( toggleKey != -1 ) { 224 if( toggleKey != -1 ) {
229 odebug << "Register key " << toggleKey << "" << oendl; 225 owarn << "Register key " << toggleKey << "" << oendl;
226
230 QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); 227 QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)");
231 // e << 4096; // Key_Escape 228 // e << 4096; // Key_Escape
232 // e << Key_F5; //4148 229 // e << Key_F5; //4148
@@ -234,15 +231,13 @@ VMemo::VMemo( QWidget *parent, const char *_name )
234 e << QCString("QPE/VMemo"); 231 e << QCString("QPE/VMemo");
235 e << QCString("toggleRecord()"); 232 e << QCString("toggleRecord()");
236 } 233 }
237 if(toggleKey == 1) 234 if(toggleKey == 0)
238 usingIcon = TRUE; 235 usingIcon = true;
239 else 236 else
240 usingIcon = FALSE; 237 usingIcon = false;
241// if( vmCfg.readNumEntry("hideIcon",0) == 1)
242 if (!usingIcon) 238 if (!usingIcon)
243 hide(); 239 hide();
244 recording = FALSE; 240 recording = false;
245 // }
246} 241}
247 242
248VMemo::~VMemo() { 243VMemo::~VMemo() {
@@ -250,7 +245,7 @@ VMemo::~VMemo() {
250 245
251int VMemo::position() 246int VMemo::position()
252{ 247{
253 return 6; 248 return 1;
254} 249}
255 250
256void VMemo::receive( const QCString &msg, const QByteArray &data ) { 251void VMemo::receive( const QCString &msg, const QByteArray &data ) {
@@ -258,10 +253,10 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) {
258 253
259 if (msg == "toggleRecord()") { 254 if (msg == "toggleRecord()") {
260 if (recording) { 255 if (recording) {
261 fromToggle = TRUE; 256 fromToggle = true;
262 stopRecording(); 257 stopRecording();
263 } else { 258 } else {
264 fromToggle = TRUE; 259 fromToggle = true;
265 startRecording(); 260 startRecording();
266 } 261 }
267 } 262 }
@@ -273,18 +268,15 @@ void VMemo::paintEvent( QPaintEvent* ) {
273} 268}
274 269
275void VMemo::mousePressEvent( QMouseEvent * /*me*/) { 270void VMemo::mousePressEvent( QMouseEvent * /*me*/) {
276 /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
277 mousePressEvent and mouseReleaseEvent with a NULL parameter. */
278
279// if (!systemZaurus && me != NULL)
280// return;
281// }
282 271
283 if(!recording) 272 if(!recording) {
284 startRecording(); 273 if(!startRecording() ){
285 else 274 QMessageBox::critical(0, "vmemo", "Abort Recording", "Abort Recording");
275 }
276 } else {
286 stopRecording(); 277 stopRecording();
287} 278}
279}
288 280
289void VMemo::mouseReleaseEvent( QMouseEvent * ) { 281void VMemo::mouseReleaseEvent( QMouseEvent * ) {
290} 282}
@@ -293,20 +285,13 @@ bool VMemo::startRecording() {
293 Config config( "Vmemo" ); 285 Config config( "Vmemo" );
294 config.setGroup( "System" ); 286 config.setGroup( "System" );
295 287
296 useAlerts = config.readBoolEntry("Alert",1);
297 if(useAlerts) {
298
299 msgLabel = new QLabel( 0, "alertLabel" );
300 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
301 msgLabel->show();
302 }
303 288
304 odebug << "Start recording engines" << oendl; 289 odebug << "Start recording engines" << oendl;
305 recording = TRUE; 290 recording = true;
306 291
307 if (openDSP() == -1) { 292 if (openDSP() == -1) {
308 recording = FALSE; 293 recording = false;
309 return FALSE; 294 return false;
310 } 295 }
311 296
312 config.setGroup("Defaults"); 297 config.setGroup("Defaults");
@@ -336,6 +321,14 @@ bool VMemo::startRecording() {
336 321
337 fileName+=fName; 322 fileName+=fName;
338 odebug << "filename is " + fileName << oendl; 323 odebug << "filename is " + fileName << oendl;
324
325 useAlerts = config.readBoolEntry("Alert",1);
326 if(useAlerts) {
327 msgLabel = new QLabel( 0, "alertLabel" );
328 msgLabel->setText( tr("<B><P><font size=+2>VMemo-Recording</font></B><p>%1</p>").arg("vm_"+ date));
329 msgLabel->show();
330 }
331
339// open tmp file here 332// open tmp file here
340 char *pointer; 333 char *pointer;
341 pointer=tmpnam(NULL); 334 pointer=tmpnam(NULL);
@@ -347,12 +340,12 @@ bool VMemo::startRecording() {
347 err += fileName; 340 err += fileName;
348 QMessageBox::critical(0, "vmemo", err, "Abort"); 341 QMessageBox::critical(0, "vmemo", err, "Abort");
349 ::close(dsp); 342 ::close(dsp);
350 return FALSE; 343 return false;
351 } 344 }
352 if( record() ) { 345 if( record() ) {
353 346
354 QString cmd; 347 QString cmd;
355 if( fileName.find(".wav",0,TRUE) == -1) 348 if( fileName.find(".wav",0,true) == -1)
356 fileName += ".wav"; 349 fileName += ".wav";
357 350
358 cmd.sprintf("mv %s "+fileName, pointer); 351 cmd.sprintf("mv %s "+fileName, pointer);
@@ -371,16 +364,16 @@ bool VMemo::startRecording() {
371 l.setType("audio/x-wav"); 364 l.setType("audio/x-wav");
372 l.setCategories(cats); 365 l.setCategories(cats);
373 l.writeLink(); 366 l.writeLink();
374 return TRUE; 367 return true;
375 } else 368 } else
376 return FALSE; 369 return false;
377 370
378} 371}
379 372
380void VMemo::stopRecording() { 373void VMemo::stopRecording() {
381// show(); 374// show();
382 odebug << "Stopped recording" << oendl; 375 odebug << "Stopped recording" << oendl;
383 recording = FALSE; 376 recording = false;
384 if(useAlerts) { 377 if(useAlerts) {
385 msgLabel->close(); 378 msgLabel->close();
386 msgLabel=0; 379 msgLabel=0;
@@ -433,22 +426,22 @@ int VMemo::openDSP() {
433 426
434 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 427 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
435 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 428 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
436 return -1; 429// return -1;
437 } 430 }
438 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 431 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
439 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 432 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
440 return -1; 433// return -1;
441 } 434 }
442 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 435 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
443 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 436 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
444 return -1; 437// return -1;
445 } 438 }
446 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 439 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
447 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 440 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
448 return -1; 441// return -1;
449 } 442 }
450 443
451 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute 444 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; //mute
452 445
453 return 1; 446 return 1;
454} 447}
@@ -506,7 +499,7 @@ bool VMemo::record() {
506 odebug << "VMEMO rate" << sRate << oendl; 499 odebug << "VMEMO rate" << sRate << oendl;
507 500
508 if(sRate > 0) { 501 if(sRate > 0) {
509 t_timer->start( sRate * 1000+1000, TRUE); 502 t_timer->start( sRate * 1000+1000, true);
510 } 503 }
511 504
512 msg.sprintf("Recording format other"); 505 msg.sprintf("Recording format other");
@@ -528,9 +521,9 @@ bool VMemo::record() {
528 if( result <= 0) { 521 if( result <= 0) {
529 perror("recording error "); 522 perror("recording error ");
530 QMessageBox::message(tr("Note"),tr("error recording")); 523 QMessageBox::message(tr("Note"),tr("error recording"));
531 recording = FALSE; 524 recording = false;
532 break; 525 break;
533 return FALSE; 526 return false;
534 } 527 }
535 adpcm_coder( sbuf, abuf, result/2, &encoder_state); 528 adpcm_coder( sbuf, abuf, result/2, &encoder_state);
536 bytesWritten = ::write(wav, abuf, result/4); // adpcm write 529 bytesWritten = ::write(wav, abuf, result/4); // adpcm write
@@ -541,7 +534,7 @@ bool VMemo::record() {
541 perror("dev/dsp's is a lookin' messy"); 534 perror("dev/dsp's is a lookin' messy");
542 QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); 535 QMessageBox::message("Vmemo","Error writing to file\n"+ fileName);
543 break; 536 break;
544 return FALSE; 537 return false;
545 } 538 }
546 printf("%d\r", length); 539 printf("%d\r", length);
547 fflush(stdout); 540 fflush(stdout);
@@ -554,9 +547,9 @@ bool VMemo::record() {
554 if( result <= 0) { 547 if( result <= 0) {
555 perror("recording error "); 548 perror("recording error ");
556 QMessageBox::message(tr("Note"),tr("error recording")); 549 QMessageBox::message(tr("Note"),tr("error recording"));
557 recording = FALSE; 550 recording = false;
558 break; 551 break;
559 return FALSE; 552 return false;
560 } 553 }
561 554
562 bytesWritten = ::write(wav, sound, result); // write 555 bytesWritten = ::write(wav, sound, result); // write
@@ -567,15 +560,14 @@ bool VMemo::record() {
567 perror("dev/dsp's is a lookin' messy"); 560 perror("dev/dsp's is a lookin' messy");
568 QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); 561 QMessageBox::message("Vmemo","Error writing to file\n"+ fileName);
569 break; 562 break;
570 return FALSE; 563 return false;
571 } 564 }
572// printf("%d\r", length); 565// printf("%d\r", length);
573// fflush(stdout); 566// fflush(stdout);
574 qApp->processEvents(); 567 qApp->processEvents();
575 } 568 }
576 // odebug << "result is " << result << oendl;
577 } 569 }
578 odebug << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl; 570 owarn << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl;
579 571
580 value = length + 36; 572 value = length + 36;
581 573
@@ -586,7 +578,6 @@ bool VMemo::record() {
586 write(wav, &length, 4); 578 write(wav, &length, 4);
587 579
588 track.close(); 580 track.close();
589 odebug << "Track closed" << oendl;
590 581
591 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 582 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
592 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 583 perror("ioctl(\"SNDCTL_DSP_RESET\")");
@@ -618,10 +609,10 @@ bool VMemo::record() {
618 609
619 Config cfg("qpe"); 610 Config cfg("qpe");
620 cfg.setGroup("Volume"); 611 cfg.setGroup("Volume");
621 QString foo = cfg.readEntry("Mute","TRUE"); 612 QString foo = cfg.readEntry("Mute","true");
622 if(foo.find("TRUE",0,TRUE) != -1) 613 if(foo.find("true",0,true) != -1)
623 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute 614 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; //mute
624 return TRUE; 615 return true;
625} 616}
626 617
627int VMemo::setToggleButton(int tog) { 618int VMemo::setToggleButton(int tog) {
@@ -667,5 +658,5 @@ void VMemo::timerBreak() {
667} 658}
668 659
669 660
670//EXPORT_OPIE_APPLET_v1( VMemo ) 661EXPORT_OPIE_APPLET_v1( VMemo )
671 662