summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 0c792c6..577db75 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -273,192 +273,193 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) {
273 startRecording(); 273 startRecording();
274 } 274 }
275 } 275 }
276} 276}
277 277
278void VMemo::paintEvent( QPaintEvent* ) { 278void VMemo::paintEvent( QPaintEvent* ) {
279 QPainter p(this); 279 QPainter p(this);
280 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 280 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
281} 281}
282 282
283void VMemo::mousePressEvent( QMouseEvent * me) { 283void VMemo::mousePressEvent( QMouseEvent * me) {
284 // just to be safe 284 // just to be safe
285 if (recording) { 285 if (recording) {
286 recording = FALSE; 286 recording = FALSE;
287 return; 287 return;
288 } 288 }
289 /* 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
290 mousePressEvent and mouseReleaseEvent with a NULL parameter. */ 290 mousePressEvent and mouseReleaseEvent with a NULL parameter. */
291 if ( me->button() != LeftButton || me != NULL) 291 if ( me->button() != LeftButton || me != NULL)
292 // if (!systemZaurus && me != NULL) 292 // if (!systemZaurus && me != NULL)
293 return; 293 return;
294 294
295 if(!recording) 295 if(!recording)
296 startRecording(); 296 startRecording();
297 else 297 else
298 stopRecording(); 298 stopRecording();
299} 299}
300 300
301void VMemo::mouseReleaseEvent( QMouseEvent * ) { 301void VMemo::mouseReleaseEvent( QMouseEvent * ) {
302// if(usingIcon && !recording) 302// if(usingIcon && !recording)
303// stopRecording(); 303// stopRecording();
304} 304}
305 305
306bool VMemo::startRecording() { 306bool VMemo::startRecording() {
307 307
308 if ( recording) 308 if ( recording)
309 return FALSE; 309 return FALSE;
310 310
311 Config config( "Vmemo" ); 311 Config config( "Vmemo" );
312 config.setGroup( "System" ); 312 config.setGroup( "System" );
313 313
314 useAlerts = config.readBoolEntry("Alert",1); 314 useAlerts = config.readBoolEntry("Alert",1);
315 if(useAlerts) { 315 if(useAlerts) {
316 316
317 msgLabel = new QLabel( 0, "alertLabel" ); 317 msgLabel = new QLabel( 0, "alertLabel" );
318 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 318 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
319 msgLabel->show(); 319 msgLabel->show();
320 } 320 }
321 321
322 // if(useAlerts) 322 // if(useAlerts)
323 // QMessageBox::message("VMemo","Really Record?");//) ==1) 323 // QMessageBox::message("VMemo","Really Record?");//) ==1)
324 // return; 324 // return;
325 // } else { 325 // } else {
326 // if (!systemZaurus ) 326 // if (!systemZaurus )
327 // QSound::play(Resource::findSound("vmemob")); 327 // QSound::play(Resource::findSound("vmemob"));
328 // } 328 // }
329 qDebug("Start recording engines"); 329 qDebug("Start recording engines");
330 recording = TRUE; 330 recording = TRUE;
331 331
332 if (openDSP() == -1) { 332 if (openDSP() == -1) {
333 // 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");
334 // delete msgLabel; 334 // delete msgLabel;
335 recording = FALSE; 335 recording = FALSE;
336 msgLabel=0; 336 msgLabel=0;
337 delete msgLabel; 337 delete msgLabel;
338 338
339 return FALSE; 339 return FALSE;
340 } 340 }
341 341
342 config.setGroup("Defaults"); 342 config.setGroup("Defaults");
343 343
344 QDateTime dt = QDateTime::currentDateTime(); 344 QDateTime dt = QDateTime::currentDateTime();
345 345
346 QString fName; 346 QString fName;
347 config.setGroup( "System" ); 347 config.setGroup( "System" );
348 fName = QPEApplication::documentDir() ; 348 fName = QPEApplication::documentDir() ;
349 fileName = config.readEntry("RecLocation", fName); 349 fileName = config.readEntry("RecLocation", fName);
350 350
351 int s; 351 int s;
352 s=fileName.find(':'); 352 s=fileName.find(':');
353 if(s) 353 if(s)
354 fileName=fileName.right(fileName.length()-s-2); 354 fileName=fileName.right(fileName.length()-s-2);
355 qDebug("pathname will be "+fileName); 355 qDebug("pathname will be "+fileName);
356 356
357 if( fileName.left(1).find('/') == -1) 357 if( fileName.left(1).find('/') == -1)
358 fileName="/"+fileName; 358 fileName="/"+fileName;
359 if( fileName.right(1).find('/') == -1) 359 if( fileName.right(1).find('/') == -1)
360 fileName+="/"; 360 fileName+="/";
361 fName = "vm_"+ dt.toString()+ ".wav"; 361 fName = "vm_"+ dt.toString()+ ".wav";
362 362
363 fileName+=fName; 363 fileName+=fName;
364 // No spaces in the filename 364 // No spaces in the filename
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 fileName.replace(QRegExp(","),"");
369 fileName += ".wav";
369 370
370 qDebug("filename is "+fileName); 371 qDebug("filename is "+fileName);
371// open tmp file here 372// open tmp file here
372 char *pointer; 373 char *pointer;
373 pointer=tmpnam(NULL); 374 pointer=tmpnam(NULL);
374 qDebug("Opening tmp file %s",pointer); 375 qDebug("Opening tmp file %s",pointer);
375 376
376 if(openWAV(pointer ) == -1) { 377 if(openWAV(pointer ) == -1) {
377 378
378// if(openWAV(fileName.latin1()) == -1) { 379// if(openWAV(fileName.latin1()) == -1) {
379 QString err("Could not open the temp file\n"); 380 QString err("Could not open the temp file\n");
380 err += fileName; 381 err += fileName;
381 QMessageBox::critical(0, "vmemo", err, "Abort"); 382 QMessageBox::critical(0, "vmemo", err, "Abort");
382 ::close(dsp); 383 ::close(dsp);
383 return FALSE; 384 return FALSE;
384 } 385 }
385 if( record() ) { 386 if( record() ) {
386 387
387 QString cmd; 388 QString cmd;
388 cmd.sprintf("mv %s "+fileName, pointer); 389 cmd.sprintf("mv %s "+fileName, pointer);
389// move tmp file to regular file here 390// move tmp file to regular file here
390 system(cmd.latin1()); 391 system(cmd.latin1());
391 392
392 QArray<int> cats(1); 393 QArray<int> cats(1);
393 cats[0] = config.readNumEntry("Category", 0); 394 cats[0] = config.readNumEntry("Category", 0);
394 395
395 QString dlName("vm_"); 396 QString dlName("vm_");
396 dlName += dt.toString(); 397 dlName += dt.toString();
397 DocLnk l; 398 DocLnk l;
398 l.setFile(fileName); 399 l.setFile(fileName);
399 l.setName(dlName); 400 l.setName(dlName);
400 l.setType("audio/x-wav"); 401 l.setType("audio/x-wav");
401 l.setCategories(cats); 402 l.setCategories(cats);
402 l.writeLink(); 403 l.writeLink();
403 return TRUE; 404 return TRUE;
404 } else 405 } else
405 return FALSE; 406 return FALSE;
406 407
407} 408}
408 409
409void VMemo::stopRecording() { 410void VMemo::stopRecording() {
410 show(); 411 show();
411 qDebug("Stopped recording"); 412 qDebug("Stopped recording");
412 recording = FALSE; 413 recording = FALSE;
413 if(useAlerts) { 414 if(useAlerts) {
414 msgLabel->close(); 415 msgLabel->close();
415 msgLabel=0; 416 msgLabel=0;
416 delete msgLabel; 417 delete msgLabel;
417 } 418 }
418 t_timer->stop(); 419 t_timer->stop();
419 Config cfg("Vmemo"); 420 Config cfg("Vmemo");
420 cfg.setGroup("Defaults"); 421 cfg.setGroup("Defaults");
421 if( cfg.readNumEntry("hideIcon",0) == 1 ) 422 if( cfg.readNumEntry("hideIcon",0) == 1 )
422 hide(); 423 hide();
423} 424}
424 425
425int VMemo::openDSP() { 426int VMemo::openDSP() {
426 Config cfg("Vmemo"); 427 Config cfg("Vmemo");
427 cfg.setGroup("Record"); 428 cfg.setGroup("Record");
428 429
429 speed = cfg.readNumEntry("SampleRate", 22050); 430 speed = cfg.readNumEntry("SampleRate", 22050);
430 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 431 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
431 if (cfg.readNumEntry("SixteenBit", 1)==1) { 432 if (cfg.readNumEntry("SixteenBit", 1)==1) {
432 format = AFMT_S16_LE; 433 format = AFMT_S16_LE;
433 resolution = 16; 434 resolution = 16;
434 } else { 435 } else {
435 format = AFMT_U8; 436 format = AFMT_U8;
436 resolution = 8; 437 resolution = 8;
437 } 438 }
438 439
439 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 440 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
440 441
441 if(systemZaurus) { 442 if(systemZaurus) {
442 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 443 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
443 channels=1; //zaurus has one input channel 444 channels=1; //zaurus has one input channel
444 } else { 445 } else {
445 dsp = open("/dev/dsp", O_RDONLY); 446 dsp = open("/dev/dsp", O_RDONLY);
446 } 447 }
447 448
448 if(dsp == -1) { 449 if(dsp == -1) {
449 perror("open(\"/dev/dsp\")"); 450 perror("open(\"/dev/dsp\")");
450 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 451 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
451 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 452 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
452 return -1; 453 return -1;
453 } 454 }
454 455
455 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 456 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
456 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 457 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
457 return -1; 458 return -1;
458 } 459 }
459 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 460 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
460 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 461 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
461 return -1; 462 return -1;
462 } 463 }
463 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 464 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
464 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 465 perror("ioctl(\"SNDCTL_DSP_SPEED\")");