author | llornkcor <llornkcor> | 2003-08-10 23:00:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-08-10 23:00:44 (UTC) |
commit | 41b3267ce7142a62ac3d3d6eef3feb33f00deda5 (patch) (side-by-side diff) | |
tree | 2b9a5d64a867101ec09e4f662acfa6d71ef36aac | |
parent | 0a95378893ef32a775182f9fa3a93381c05a9670 (diff) | |
download | opie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.zip opie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.tar.gz opie-41b3267ce7142a62ac3d3d6eef3feb33f00deda5.tar.bz2 |
change filename used, and other things
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 62 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 3 |
2 files changed, 37 insertions, 28 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 @@ -8,35 +8,31 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ************************************************************************************/ // copyright 2002 Jeremy Cowgar <jc@cowgar.com> /* * $Id$ */ -// Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> +// copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> + extern "C" { #include "adpcm.h" } -#include <sys/utsname.h> -#include <sys/time.h> -#include <sys/types.h> #include <unistd.h> #include <stdio.h> -#include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/soundcard.h> -#include <string.h> -#include <stdlib.h> #include <errno.h> + typedef struct _waveheader { u_long main_chunk; /* 'RIFF' */ u_long length; /* filelen */ u_long chunk_type; /* 'WAVE' */ u_long sub_chunk; /* 'fmt ' */ u_long sc_len; /* length of sub_chunk, =16 (chunckSize) format len */ u_short format; /* should be 1 for PCM-code (formatTag) */ @@ -203,28 +199,23 @@ static char * vmemo_xpm[] = { VMemo::VMemo( QWidget *parent, const char *_name ) : QWidget( parent, _name ) { setFixedHeight( 18 ); setFixedWidth( 14 ); t_timer = new QTimer( this ); connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); - struct utsname name; /* check for embedix kernel running on the zaurus*/ - if (uname(&name) != -1) { - QString release=name.release; - Config vmCfg("Vmemo"); vmCfg.setGroup("Defaults"); int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); qDebug("toggleKey %d", toggleKey); - - if(release.find("embedix",0,TRUE) !=-1) + if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) systemZaurus=TRUE; else systemZaurus=FALSE; myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); @@ -239,17 +230,17 @@ VMemo::VMemo( QWidget *parent, const char *_name ) } if(toggleKey == 1) usingIcon=TRUE; else usingIcon=FALSE; if( vmCfg.readNumEntry("hideIcon",0) == 1) hide(); recording = FALSE; - } + // } } VMemo::~VMemo() { } void VMemo::receive( const QCString &msg, const QByteArray &data ) { qDebug("receive"); QDataStream stream( data, IO_ReadOnly ); @@ -304,52 +295,48 @@ bool VMemo::startRecording() { if (openDSP() == -1) { recording = FALSE; return FALSE; } config.setGroup("Defaults"); - QDateTime dt = QDateTime::currentDateTime(); + date = TimeString::dateString( QDateTime::currentDateTime(),false,true); + date.replace(QRegExp("'"),""); + date.replace(QRegExp(" "),"_"); + date.replace(QRegExp(":"),"."); + date.replace(QRegExp(","),""); QString fName; config.setGroup( "System" ); fName = QPEApplication::documentDir() ; fileName = config.readEntry("RecLocation", fName); int s; s=fileName.find(':'); if(s) fileName=fileName.right(fileName.length()-s-2); qDebug("pathname will be "+fileName); if( fileName.left(1).find('/') == -1) fileName="/"+fileName; if( fileName.right(1).find('/') == -1) fileName+="/"; - fName = "vm_"+ dt.toString()+ ".wav"; + fName = "vm_"+ date+ ".wav"; fileName+=fName; - // No spaces in the filename - fileName.replace(QRegExp("'"),""); - fileName.replace(QRegExp(" "),"_"); - fileName.replace(QRegExp(":"),"."); - fileName.replace(QRegExp(","),""); - - qDebug("filename is "+fileName); // open tmp file here char *pointer; pointer=tmpnam(NULL); qDebug("Opening tmp file %s",pointer); if(openWAV(pointer ) == -1) { -// if(openWAV(fileName.latin1()) == -1) { QString err("Could not open the temp file\n"); err += fileName; QMessageBox::critical(0, "vmemo", err, "Abort"); ::close(dsp); return FALSE; } if( record() ) { @@ -361,17 +348,17 @@ bool VMemo::startRecording() { // move tmp file to regular file here system(cmd.latin1()); QArray<int> cats(1); cats[0] = config.readNumEntry("Category", 0); QString dlName("vm_"); - dlName += dt.toString(); + dlName += date; DocLnk l; l.setFile(fileName); l.setName(dlName); l.setType("audio/x-wav"); l.setCategories(cats); l.writeLink(); return TRUE; } else @@ -484,18 +471,18 @@ int VMemo::openWAV(const char *filename) { // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); write (wav, &wh, sizeof(WaveHeader)); return 1; } bool VMemo::record() { - - int length=0, result, value; + length=0; + int result, value; QString msg; msg.sprintf("Recording format %d", format); qDebug(msg); Config config("Vmemo"); config.setGroup("Record"); int sRate=config.readNumEntry("SizeLimit", 30); if(sRate > 0) t_timer->start( sRate * 1000+1000, TRUE); @@ -571,16 +558,37 @@ bool VMemo::record() { track.close(); qDebug("Track closed"); if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); ::close(dsp); + Config cfgO("OpieRec"); + cfgO.setGroup("Sounds"); + + int nFiles = cfgO.readNumEntry( "NumberofFiles",0); + + QString currentFileName = fileName; + QString currentFile = "vm_"+ date; + + float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; + + cfgO.writeEntry( "NumberofFiles", nFiles + 1); + cfgO.writeEntry( QString::number( nFiles + 1), currentFile); + cfgO.writeEntry( currentFile, currentFileName); + + QString time; + time.sprintf("%.2f", numberOfRecordedSeconds); + cfgO.writeEntry( currentFileName, time ); + // qDebug("writing config numberOfRecordedSeconds "+time); + + cfgO.write(); + qDebug("done recording "+fileName); Config cfg("qpe"); cfg.setGroup("Volume"); QString foo = cfg.readEntry("Mute","TRUE"); if(foo.find("TRUE",0,TRUE) != -1) QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute return TRUE; 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 @@ -28,17 +28,18 @@ class VMemo : public QWidget { Q_OBJECT public: VMemo( QWidget *parent, const char *name = NULL); ~VMemo(); QFile track; - QString fileName, errorMsg; + int length; + QString fileName, errorMsg, date; QLabel* msgLabel; QTimer *t_timer; bool usingIcon, useADPCM; public slots: bool record(); void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); void receive( const QCString &msg, const QByteArray &data ); |