summaryrefslogtreecommitdiff
path: root/core/applets
Unidiff
Diffstat (limited to 'core/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 84d53e0..2d694d2 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -206,12 +206,13 @@ VMemo::VMemo( QWidget *parent, const char *_name )
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 struct utsname name; /* check for embedix kernel running on the zaurus*/ 209 struct utsname name; /* check for embedix kernel running on the zaurus*/
210 if (uname(&name) != -1) { 210 if (uname(&name) != -1) {
211 QString release=name.release; 211 QString release=name.release;
212
212 Config vmCfg("Vmemo"); 213 Config vmCfg("Vmemo");
213 vmCfg.setGroup("Defaults"); 214 vmCfg.setGroup("Defaults");
214 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 215 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
215 216
216 qDebug("toggleKey %d", toggleKey); 217 qDebug("toggleKey %d", toggleKey);
217 218
@@ -230,23 +231,25 @@ VMemo::VMemo( QWidget *parent, const char *_name )
230 // e << 4096; // Key_Escape 231 // e << 4096; // Key_Escape
231 // e << Key_F5; //4148 232 // e << Key_F5; //4148
232 e << toggleKey; 233 e << toggleKey;
233 e << QString("QPE/VMemo"); 234 e << QString("QPE/VMemo");
234 e << QString("toggleRecord()"); 235 e << QString("toggleRecord()");
235 } 236 }
236 if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) 237
238 if( vmCfg.readNumEntry("hideIcon",0) == 1)
237 hide(); 239 hide();
238 } 240 }
239} 241}
240 242
241VMemo::~VMemo() 243VMemo::~VMemo()
242{ 244{
243} 245}
244 246
245void VMemo::receive( const QCString &msg, const QByteArray &data ) 247void VMemo::receive( const QCString &msg, const QByteArray &data )
246{ 248{
249 qDebug("receive");
247 QDataStream stream( data, IO_ReadOnly ); 250 QDataStream stream( data, IO_ReadOnly );
248 if (msg == "toggleRecord()") { 251 if (msg == "toggleRecord()") {
249 if (recording) { 252 if (recording) {
250 fromToggle = TRUE; 253 fromToggle = TRUE;
251 stopRecording(); 254 stopRecording();
252 } else { 255 } else {
@@ -272,13 +275,13 @@ void VMemo::mouseReleaseEvent( QMouseEvent * )
272 stopRecording(); 275 stopRecording();
273} 276}
274 277
275bool VMemo::startRecording() { 278bool VMemo::startRecording() {
276 279
277 if ( recording) 280 if ( recording)
278 return FALSE;; 281 return FALSE;
279 282
280 Config config( "Vmemo" ); 283 Config config( "Vmemo" );
281 config.setGroup( "System" ); 284 config.setGroup( "System" );
282 285
283 useAlerts = config.readBoolEntry("Alert"); 286 useAlerts = config.readBoolEntry("Alert");
284 if(useAlerts) { 287 if(useAlerts) {
@@ -315,13 +318,14 @@ bool VMemo::startRecording() {
315 fileName = config.readEntry("RecLocation", fName); 318 fileName = config.readEntry("RecLocation", fName);
316 319
317 int s; 320 int s;
318 s=fileName.find(':'); 321 s=fileName.find(':');
319 if(s) 322 if(s)
320 fileName=fileName.right(fileName.length()-s-2); 323 fileName=fileName.right(fileName.length()-s-2);
321 qDebug("filename will be "+fileName); 324 qDebug("pathname will be "+fileName);
325
322 if( fileName.left(1).find('/') == -1) 326 if( fileName.left(1).find('/') == -1)
323 fileName="/"+fileName; 327 fileName="/"+fileName;
324 if( fileName.right(1).find('/') == -1) 328 if( fileName.right(1).find('/') == -1)
325 fileName+="/"; 329 fileName+="/";
326 fName = "vm_"+ dt.toString()+ ".wav"; 330 fName = "vm_"+ dt.toString()+ ".wav";
327 331
@@ -331,13 +335,13 @@ bool VMemo::startRecording() {
331 fileName.replace(QRegExp("'"),""); 335 fileName.replace(QRegExp("'"),"");
332 fileName.replace(QRegExp(" "),"_"); 336 fileName.replace(QRegExp(" "),"_");
333 fileName.replace(QRegExp(":"),"."); 337 fileName.replace(QRegExp(":"),".");
334 fileName.replace(QRegExp(","),""); 338 fileName.replace(QRegExp(","),"");
335 339
336 if(openWAV(fileName.latin1()) == -1) { 340 if(openWAV(fileName.latin1()) == -1) {
337 // QString err("Could not open the output file\n"); 341 // QString err("Could not open the output file\n");
338 // err += fileName; 342 // err += fileName;
339 // QMessageBox::critical(0, "vmemo", err, "Abort"); 343 // QMessageBox::critical(0, "vmemo", err, "Abort");
340 close(dsp); 344 close(dsp);
341 return FALSE; 345 return FALSE;
342 } 346 }
343 347
@@ -357,16 +361,22 @@ bool VMemo::startRecording() {
357 record(); 361 record();
358 // delete msgLabel; 362 // delete msgLabel;
359 return TRUE; 363 return TRUE;
360} 364}
361 365
362void VMemo::stopRecording() { 366void VMemo::stopRecording() {
367show();
368 qDebug("Stopped recording");
363 recording = FALSE; 369 recording = FALSE;
364 if(useAlerts) 370 if(useAlerts)
365 if( msgLabel) delete msgLabel; 371 if( msgLabel) delete msgLabel;
366 t_timer->stop(); 372 t_timer->stop();
373 Config cfg("Vmemo");
374 cfg.setGroup("Defaults");
375 if( cfg.readNumEntry("hideIcon",0) == 1 )
376 hide();
367} 377}
368 378
369int VMemo::openDSP() 379int VMemo::openDSP()
370{ 380{
371 Config cfg("Vmemo"); 381 Config cfg("Vmemo");
372 cfg.setGroup("Record"); 382 cfg.setGroup("Record");
@@ -381,16 +391,16 @@ int VMemo::openDSP()
381 resolution = 8; 391 resolution = 8;
382 } 392 }
383 393
384 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 394 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
385 395
386 if(systemZaurus) { 396 if(systemZaurus) {
387 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 397 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
388 channels=1; //zaurus has one input channel 398 channels=1; //zaurus has one input channel
389 } else { 399 } else {
390 dsp = open("/dev/dsp", O_RDWR); 400 dsp = open("/dev/dsp", O_RDONLY);
391 } 401 }
392 402
393 if(dsp == -1) { 403 if(dsp == -1) {
394 perror("open(\"/dev/dsp\")"); 404 perror("open(\"/dev/dsp\")");
395 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 405 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
396 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 406 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
@@ -562,22 +572,23 @@ void VMemo::record(void)
562 write(wav, &value, 4); 572 write(wav, &value, 4);
563 lseek(wav, 40, SEEK_SET); 573 lseek(wav, 40, SEEK_SET);
564 574
565 write(wav, &length, 4); 575 write(wav, &length, 4);
566 576
567 track.close(); 577 track.close();
568 qDebug("Tracvk closed"); 578 qDebug("Track closed");
569 579
570 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 580 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
571 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 581 perror("ioctl(\"SNDCTL_DSP_RESET\")");
572 582
573 ::close(dsp); 583 ::close(dsp);
574 fileName = fileName.left(fileName.length()-4); 584 fileName = fileName.left(fileName.length()-4);
575 // if(useAlerts) 585 // if(useAlerts)
576 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 586 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
577 qDebug("done recording "+fileName); 587 qDebug("done recording "+fileName);
588
578 QSound::play(Resource::findSound("vmemoe")); 589 QSound::play(Resource::findSound("vmemoe"));
579 590
580 Config cfg("qpe"); 591 Config cfg("qpe");
581 cfg.setGroup("Volume"); 592 cfg.setGroup("Volume");
582 QString foo = cfg.readEntry("Mute","TRUE"); 593 QString foo = cfg.readEntry("Mute","TRUE");
583 if(foo.find("TRUE",0,TRUE) != -1) 594 if(foo.find("TRUE",0,TRUE) != -1)