summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-08-10 23:00:44 (UTC)
committer llornkcor <llornkcor>2003-08-10 23:00:44 (UTC)
commit41b3267ce7142a62ac3d3d6eef3feb33f00deda5 (patch) (unidiff)
tree2b9a5d64a867101ec09e4f662acfa6d71ef36aac
parent0a95378893ef32a775182f9fa3a93381c05a9670 (diff)
downloadopie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.zip
opie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.tar.gz
opie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.tar.bz2
change filename used, and other things
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp70
-rw-r--r--core/applets/vmemo/vmemo.h5
2 files changed, 42 insertions, 33 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 7af3d8b..6ec4583 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -10,31 +10,27 @@
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// copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com>
17
17extern "C" { 18extern "C" {
18#include "adpcm.h" 19#include "adpcm.h"
19} 20}
20 21
21#include <sys/utsname.h>
22#include <sys/time.h>
23#include <sys/types.h>
24#include <unistd.h> 22#include <unistd.h>
25#include <stdio.h> 23#include <stdio.h>
26#include <sys/stat.h>
27#include <fcntl.h> 24#include <fcntl.h>
28#include <sys/ioctl.h> 25#include <sys/ioctl.h>
29#include <linux/soundcard.h> 26#include <linux/soundcard.h>
30 27
31#include <string.h>
32#include <stdlib.h>
33#include <errno.h> 28#include <errno.h>
34 29
30
35typedef struct _waveheader { 31typedef struct _waveheader {
36 u_long main_chunk; /* 'RIFF' */ 32 u_long main_chunk; /* 'RIFF' */
37 u_long length; /* filelen */ 33 u_long length; /* filelen */
38 u_long chunk_type; /* 'WAVE' */ 34 u_long chunk_type; /* 'WAVE' */
39 u_long sub_chunk; /* 'fmt ' */ 35 u_long sub_chunk; /* 'fmt ' */
40 u_long sc_len; /* length of sub_chunk, =16 36 u_long sc_len; /* length of sub_chunk, =16
@@ -205,25 +201,20 @@ VMemo::VMemo( QWidget *parent, const char *_name )
205 setFixedHeight( 18 ); 201 setFixedHeight( 18 );
206 setFixedWidth( 14 ); 202 setFixedWidth( 14 );
207 203
208 t_timer = new QTimer( this ); 204 t_timer = new QTimer( this );
209 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 205 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
210 206
211 struct utsname name; /* check for embedix kernel running on the zaurus*/
212 if (uname(&name) != -1) {
213 QString release=name.release;
214
215 Config vmCfg("Vmemo"); 207 Config vmCfg("Vmemo");
216 vmCfg.setGroup("Defaults"); 208 vmCfg.setGroup("Defaults");
217 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 209 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
218 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); 210 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
219 211
220 qDebug("toggleKey %d", toggleKey); 212 qDebug("toggleKey %d", toggleKey);
221 213 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
222 if(release.find("embedix",0,TRUE) !=-1) 214 systemZaurus=TRUE;
223 systemZaurus=TRUE;
224 else 215 else
225 systemZaurus=FALSE; 216 systemZaurus=FALSE;
226 217
227 myChannel = new QCopChannel( "QPE/VMemo", this ); 218 myChannel = new QCopChannel( "QPE/VMemo", this );
228 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 219 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
229 this, SLOT(receive(const QCString&, const QByteArray&)) ); 220 this, SLOT(receive(const QCString&, const QByteArray&)) );
@@ -241,13 +232,13 @@ VMemo::VMemo( QWidget *parent, const char *_name )
241 usingIcon=TRUE; 232 usingIcon=TRUE;
242 else 233 else
243 usingIcon=FALSE; 234 usingIcon=FALSE;
244 if( vmCfg.readNumEntry("hideIcon",0) == 1) 235 if( vmCfg.readNumEntry("hideIcon",0) == 1)
245 hide(); 236 hide();
246 recording = FALSE; 237 recording = FALSE;
247 } 238 // }
248} 239}
249 240
250VMemo::~VMemo() { 241VMemo::~VMemo() {
251} 242}
252 243
253void VMemo::receive( const QCString &msg, const QByteArray &data ) { 244void VMemo::receive( const QCString &msg, const QByteArray &data ) {
@@ -305,14 +296,18 @@ bool VMemo::startRecording() {
305 if (openDSP() == -1) { 296 if (openDSP() == -1) {
306 recording = FALSE; 297 recording = FALSE;
307 return FALSE; 298 return FALSE;
308 } 299 }
309 300
310 config.setGroup("Defaults"); 301 config.setGroup("Defaults");
311 302
312 QDateTime dt = QDateTime::currentDateTime(); 303 date = TimeString::dateString( QDateTime::currentDateTime(),false,true);
304 date.replace(QRegExp("'"),"");
305 date.replace(QRegExp(" "),"_");
306 date.replace(QRegExp(":"),".");
307 date.replace(QRegExp(","),"");
313 308
314 QString fName; 309 QString fName;
315 config.setGroup( "System" ); 310 config.setGroup( "System" );
316 fName = QPEApplication::documentDir() ; 311 fName = QPEApplication::documentDir() ;
317 fileName = config.readEntry("RecLocation", fName); 312 fileName = config.readEntry("RecLocation", fName);
318 313
@@ -323,31 +318,23 @@ bool VMemo::startRecording() {
323 qDebug("pathname will be "+fileName); 318 qDebug("pathname will be "+fileName);
324 319
325 if( fileName.left(1).find('/') == -1) 320 if( fileName.left(1).find('/') == -1)
326 fileName="/"+fileName; 321 fileName="/"+fileName;
327 if( fileName.right(1).find('/') == -1) 322 if( fileName.right(1).find('/') == -1)
328 fileName+="/"; 323 fileName+="/";
329 fName = "vm_"+ dt.toString()+ ".wav"; 324 fName = "vm_"+ date+ ".wav";
330 325
331 fileName+=fName; 326 fileName+=fName;
332 // No spaces in the filename
333 fileName.replace(QRegExp("'"),"");
334 fileName.replace(QRegExp(" "),"_");
335 fileName.replace(QRegExp(":"),".");
336 fileName.replace(QRegExp(","),"");
337
338
339 qDebug("filename is "+fileName); 327 qDebug("filename is "+fileName);
340// open tmp file here 328// open tmp file here
341 char *pointer; 329 char *pointer;
342 pointer=tmpnam(NULL); 330 pointer=tmpnam(NULL);
343 qDebug("Opening tmp file %s",pointer); 331 qDebug("Opening tmp file %s",pointer);
344 332
345 if(openWAV(pointer ) == -1) { 333 if(openWAV(pointer ) == -1) {
346 334
347// if(openWAV(fileName.latin1()) == -1) {
348 QString err("Could not open the temp file\n"); 335 QString err("Could not open the temp file\n");
349 err += fileName; 336 err += fileName;
350 QMessageBox::critical(0, "vmemo", err, "Abort"); 337 QMessageBox::critical(0, "vmemo", err, "Abort");
351 ::close(dsp); 338 ::close(dsp);
352 return FALSE; 339 return FALSE;
353 } 340 }
@@ -363,13 +350,13 @@ bool VMemo::startRecording() {
363 system(cmd.latin1()); 350 system(cmd.latin1());
364 351
365 QArray<int> cats(1); 352 QArray<int> cats(1);
366 cats[0] = config.readNumEntry("Category", 0); 353 cats[0] = config.readNumEntry("Category", 0);
367 354
368 QString dlName("vm_"); 355 QString dlName("vm_");
369 dlName += dt.toString(); 356 dlName += date;
370 DocLnk l; 357 DocLnk l;
371 l.setFile(fileName); 358 l.setFile(fileName);
372 l.setName(dlName); 359 l.setName(dlName);
373 l.setType("audio/x-wav"); 360 l.setType("audio/x-wav");
374 l.setCategories(cats); 361 l.setCategories(cats);
375 l.writeLink(); 362 l.writeLink();
@@ -486,14 +473,14 @@ int VMemo::openWAV(const char *filename) {
486 write (wav, &wh, sizeof(WaveHeader)); 473 write (wav, &wh, sizeof(WaveHeader));
487 474
488 return 1; 475 return 1;
489} 476}
490 477
491bool VMemo::record() { 478bool VMemo::record() {
492 479 length=0;
493 int length=0, result, value; 480 int result, value;
494 QString msg; 481 QString msg;
495 msg.sprintf("Recording format %d", format); 482 msg.sprintf("Recording format %d", format);
496 qDebug(msg); 483 qDebug(msg);
497 Config config("Vmemo"); 484 Config config("Vmemo");
498 config.setGroup("Record"); 485 config.setGroup("Record");
499 int sRate=config.readNumEntry("SizeLimit", 30); 486 int sRate=config.readNumEntry("SizeLimit", 30);
@@ -573,13 +560,34 @@ bool VMemo::record() {
573 560
574 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 561 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
575 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 562 perror("ioctl(\"SNDCTL_DSP_RESET\")");
576 563
577 ::close(dsp); 564 ::close(dsp);
578 565
579 qDebug("done recording "+fileName); 566 Config cfgO("OpieRec");
567 cfgO.setGroup("Sounds");
568
569 int nFiles = cfgO.readNumEntry( "NumberofFiles",0);
570
571 QString currentFileName = fileName;
572 QString currentFile = "vm_"+ date;
573
574 float numberOfRecordedSeconds=(float) length / (float)speed * (float)2;
575
576 cfgO.writeEntry( "NumberofFiles", nFiles + 1);
577 cfgO.writeEntry( QString::number( nFiles + 1), currentFile);
578 cfgO.writeEntry( currentFile, currentFileName);
579
580 QString time;
581 time.sprintf("%.2f", numberOfRecordedSeconds);
582 cfgO.writeEntry( currentFileName, time );
583 // qDebug("writing config numberOfRecordedSeconds "+time);
584
585 cfgO.write();
586
587 qDebug("done recording "+fileName);
580 588
581 Config cfg("qpe"); 589 Config cfg("qpe");
582 cfg.setGroup("Volume"); 590 cfg.setGroup("Volume");
583 QString foo = cfg.readEntry("Mute","TRUE"); 591 QString foo = cfg.readEntry("Mute","TRUE");
584 if(foo.find("TRUE",0,TRUE) != -1) 592 if(foo.find("TRUE",0,TRUE) != -1)
585 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute 593 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 9ee08ff..31d0a25 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -29,14 +29,15 @@
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 int length;
37 QString fileName, errorMsg, date;
37 QLabel* msgLabel; 38 QLabel* msgLabel;
38 QTimer *t_timer; 39 QTimer *t_timer;
39bool usingIcon, useADPCM; 40bool usingIcon, useADPCM;
40public slots: 41public slots:
41 bool record(); 42 bool record();
42 void mousePressEvent( QMouseEvent * ); 43 void mousePressEvent( QMouseEvent * );