summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp44
-rw-r--r--core/applets/vmemo/vmemo.h2
2 files changed, 27 insertions, 19 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index b5239eb..035965e 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -259,18 +259,20 @@ VMemo::~VMemo() {
void VMemo::receive( const QCString &msg, const QByteArray &data ) {
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
+
if (msg == "toggleRecord()") {
- if (recording) {
- fromToggle = TRUE;
- mouseReleaseEvent(NULL);
-// stopRecording();
- } else {
- fromToggle = TRUE;
- // mousePressEvent(NULL);
- startRecording();
- }
+
+ if (recording) {
+ fromToggle = TRUE;
+ mouseReleaseEvent(NULL);
+ stopRecording();
+ } else {
+ fromToggle = TRUE;
+ // mousePressEvent(NULL);
+ startRecording();
+ }
}
}
void VMemo::paintEvent( QPaintEvent* ) {
@@ -358,15 +360,15 @@ bool VMemo::startRecording() {
fileName+="/";
fName = "vm_"+ dt.toString()+ ".wav";
fileName+=fName;
- qDebug("filename is "+fileName);
// 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);
@@ -379,9 +381,9 @@ bool VMemo::startRecording() {
QMessageBox::critical(0, "vmemo", err, "Abort");
::close(dsp);
return FALSE;
}
- record();
+ if( record() ) {
QString cmd;
cmd.sprintf("mv %s "+fileName, pointer);
// move tmp file to regular file here
@@ -397,10 +399,12 @@ bool VMemo::startRecording() {
l.setName(dlName);
l.setType("audio/x-wav");
l.setCategories(cats);
l.writeLink();
-
return TRUE;
+ } else
+ return FALSE;
+
}
void VMemo::stopRecording() {
show();
@@ -503,18 +507,19 @@ int VMemo::openWAV(const char *filename) {
return 1;
}
-void VMemo::record(void) {
- int length=0, result, value;
+bool VMemo::record() {
+
+ int length=0, result, value;
QString msg;
msg.sprintf("Recording format %d", format);
qDebug(msg);
Config config("Vmemo");
config.setGroup("Record");
int sRate=config.readNumEntry("SizeLimit", 30);
-
- t_timer->start( sRate * 1000+1000, TRUE);
+ if(sRate > 0)
+ t_timer->start( sRate * 1000+1000, TRUE);
// if(systemZaurus) {
// } else { // 16 bit only capabilities
@@ -536,10 +541,11 @@ void VMemo::record(void) {
if( result <= 0) {
perror("recording error ");
// qDebug(currentFileName);
QMessageBox::message(tr("Note"),tr("error recording"));
- recording=FALSE;;
+ recording=FALSE;
break;
+ return FALSE;
}
if(useADPCM) {
adpcm_coder( sbuf, abuf, result/2, &encoder_state);
@@ -557,8 +563,10 @@ void VMemo::record(void) {
if(length<0) {
recording=false;
perror("dev/dsp's is a lookin' messy");
QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
+ break;
+ return FALSE;
}
// printf("%d\r",length);
// fflush(stdout);
qApp->processEvents();
@@ -596,9 +604,9 @@ void VMemo::record(void) {
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;
}
int VMemo::setToggleButton(int tog) {
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 167af2a..9ee08ff 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -37,9 +37,9 @@ public:
QLabel* msgLabel;
QTimer *t_timer;
bool usingIcon, useADPCM;
public slots:
- void record();
+ bool record();
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void receive( const QCString &msg, const QByteArray &data );
bool startRecording();