-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 71 |
1 files changed, 25 insertions, 46 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index aa23ba7..48dd193 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -152,7 +152,6 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
152 | { | 152 | { |
153 | QString release=name.release; | 153 | QString release=name.release; |
154 | qWarning("System release: %s\n", name.release); | ||
155 | if(release.find("embedix",0,TRUE) !=-1) | 154 | if(release.find("embedix",0,TRUE) !=-1) |
156 | systemZaurus=TRUE; | 155 | systemZaurus=TRUE; |
157 | else | 156 | else |
158 | { | 157 | { |
@@ -166,5 +165,4 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
166 | } | 165 | } |
167 | } | 166 | } |
168 | qWarning("VMemo done init"); | ||
169 | } | 167 | } |
170 | 168 | ||
@@ -175,13 +173,12 @@ VMemo::~VMemo() | |||
175 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 173 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
176 | { | 174 | { |
177 | QDataStream stream( data, IO_ReadOnly ); | 175 | QDataStream stream( data, IO_ReadOnly ); |
178 | qWarning("VMemo::receive: %s", (const char *)msg); | 176 | if (msg == "toggleRecord()") |
179 | if (msg == "toggleRecord()") | 177 | { |
180 | { | 178 | if (recording) |
181 | if (recording) | 179 | mouseReleaseEvent(NULL); |
182 | mouseReleaseEvent(NULL); | 180 | else |
183 | else | 181 | mousePressEvent(NULL); |
184 | mousePressEvent(NULL); | 182 | } |
185 | } | ||
186 | } | 183 | } |
187 | 184 | ||
@@ -192,5 +189,5 @@ void VMemo::paintEvent( QPaintEvent* ) | |||
192 | } | 189 | } |
193 | 190 | ||
194 | void VMemo::mousePressEvent( QMouseEvent * ) | 191 | void VMemo::mousePressEvent( QMouseEvent *me ) |
195 | { | 192 | { |
196 | // just to be safe | 193 | // just to be safe |
@@ -200,13 +197,17 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
200 | return; | 197 | return; |
201 | } | 198 | } |
199 | |||
200 | /* | ||
201 | No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | ||
202 | mousePressEvent and mouseReleaseEvent with a NULL parameter. | ||
203 | */ | ||
204 | if (!systemZaurus && me != NULL) | ||
205 | return; | ||
202 | 206 | ||
203 | qWarning("VMemo::mousePress()"); | ||
204 | QSound::play(Resource::findSound("vmemob")); | 207 | QSound::play(Resource::findSound("vmemob")); |
205 | 208 | ||
206 | recording = TRUE; | 209 | recording = TRUE; |
207 | qWarning("VMemo::mousePress() -> Starting to record"); | ||
208 | if (openDSP() == -1) | 210 | if (openDSP() == -1) |
209 | { | 211 | { |
210 | // ### Display an error box | ||
211 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); | 212 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); |
212 | recording = FALSE; | 213 | recording = FALSE; |
@@ -219,4 +220,5 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
219 | QDateTime dt = QDateTime::currentDateTime(); | 220 | QDateTime dt = QDateTime::currentDateTime(); |
220 | QString fileName; | 221 | QString fileName; |
222 | |||
221 | if(systemZaurus) | 223 | if(systemZaurus) |
222 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs | 224 | fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs |
@@ -236,6 +238,8 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
236 | if(openWAV(fileName.latin1()) == -1) | 238 | if(openWAV(fileName.latin1()) == -1) |
237 | { | 239 | { |
238 | // ### Display an error box | 240 | QString err("Could not open the output file: "); |
239 | qWarning("VMemo::mousePress() -> WAV error"); | 241 | err += fileName; |
242 | |||
243 | QMessageBox::critical(0, "VMemo", err, "Abort"); | ||
240 | close(dsp); | 244 | close(dsp); |
241 | return; | 245 | return; |
@@ -259,5 +263,4 @@ void VMemo::mousePressEvent( QMouseEvent * ) | |||
259 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
260 | { | 264 | { |
261 | qWarning("VMemo::mouseRelese() -> Done recording"); | ||
262 | recording = FALSE; | 265 | recording = FALSE; |
263 | } | 266 | } |
@@ -321,11 +324,8 @@ int VMemo::openDSP() | |||
321 | int VMemo::openWAV(const char *filename) | 324 | int VMemo::openWAV(const char *filename) |
322 | { | 325 | { |
323 | qDebug("Creating %s ",filename); | ||
324 | track.setName(filename); | 326 | track.setName(filename); |
325 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) | 327 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) |
326 | { | ||
327 | qDebug("Could not open file"); | ||
328 | return -1; | 328 | return -1; |
329 | } | 329 | |
330 | wav=track.handle(); | 330 | wav=track.handle(); |
331 | 331 | ||
@@ -354,8 +354,6 @@ int VMemo::openWAV(const char *filename) | |||
354 | void VMemo::record(void) | 354 | void VMemo::record(void) |
355 | { | 355 | { |
356 | int length=0, result, value; //, i; | 356 | int length=0, result, value; |
357 | char sound[512]; //, leftBuffer[256], rightBuffer[256]; | 357 | char sound[512]; |
358 | |||
359 | qWarning("VMemo::record()"); | ||
360 | 358 | ||
361 | while(recording) | 359 | while(recording) |
@@ -364,17 +362,4 @@ void VMemo::record(void) | |||
364 | qApp->processEvents(); | 362 | qApp->processEvents(); |
365 | 363 | ||
366 | /* attempt to write only one channel...didnt work. | ||
367 | for (i = 0; i < result; i++) { | ||
368 | leftBuffer[i] = sound[2*i]; | ||
369 | rightBuffer[i] = sound[2*i+1]; | ||
370 | } | ||
371 | */ | ||
372 | qApp->processEvents(); | ||
373 | |||
374 | /* needed to only write one channel. comment out above "write/length" code. | ||
375 | write(wav, leftBuffer, result / 2); | ||
376 | length += result/2; | ||
377 | */ | ||
378 | |||
379 | write(wav, sound, result); | 364 | write(wav, sound, result); |
380 | length += result; | 365 | length += result; |
@@ -383,7 +368,4 @@ void VMemo::record(void) | |||
383 | } | 368 | } |
384 | 369 | ||
385 | qWarning("VMemo::record() -> Done recording"); | ||
386 | qWarning("VMemo::record() -> Closing dsp"); | ||
387 | |||
388 | value = length+36; | 370 | value = length+36; |
389 | lseek(wav, 4, SEEK_SET); | 371 | lseek(wav, 4, SEEK_SET); |
@@ -397,7 +379,4 @@ void VMemo::record(void) | |||
397 | ::close(dsp); | 379 | ::close(dsp); |
398 | 380 | ||
399 | qWarning("VMemo::record() -> playing done recording sound"); | ||
400 | QSound::play(Resource::findSound("vmemoe")); | 381 | QSound::play(Resource::findSound("vmemoe")); |
401 | qWarning("VMemo::record() -> terminating"); | ||
402 | //QMessageBox::information(0, "VMemo", "Recording Done", 1); | ||
403 | } | 382 | } |