author | llornkcor <llornkcor> | 2002-05-23 02:58:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-23 02:58:32 (UTC) |
commit | 999d033f887064f5e1ddfd492f12a7f1ede72887 (patch) (unidiff) | |
tree | d8cd02814fa2edda14353fca8a0eaa39651092ea | |
parent | 375cce9ad697f99d54f3e1c60c6d197b535ed04e (diff) | |
download | opie-999d033f887064f5e1ddfd492f12a7f1ede72887.zip opie-999d033f887064f5e1ddfd492f12a7f1ede72887.tar.gz opie-999d033f887064f5e1ddfd492f12a7f1ede72887.tar.bz2 |
workaround for bug with QPEApplication::documentDir() returning 'root/...' instead of '/root/...'
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7cc4062..f5d2b20 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -241,130 +241,132 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) | |||
241 | if (msg == "toggleRecord()") { | 241 | if (msg == "toggleRecord()") { |
242 | if (recording) { | 242 | if (recording) { |
243 | fromToggle = TRUE; | 243 | fromToggle = TRUE; |
244 | stopRecording(); | 244 | stopRecording(); |
245 | } else { | 245 | } else { |
246 | fromToggle = TRUE; | 246 | fromToggle = TRUE; |
247 | startRecording(); | 247 | startRecording(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | void VMemo::paintEvent( QPaintEvent* ) | 252 | void VMemo::paintEvent( QPaintEvent* ) |
253 | { | 253 | { |
254 | QPainter p(this); | 254 | QPainter p(this); |
255 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 255 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void VMemo::mousePressEvent( QMouseEvent * ) | 258 | void VMemo::mousePressEvent( QMouseEvent * ) |
259 | { | 259 | { |
260 | startRecording(); | 260 | startRecording(); |
261 | } | 261 | } |
262 | 262 | ||
263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 263 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
264 | { | 264 | { |
265 | stopRecording(); | 265 | stopRecording(); |
266 | } | 266 | } |
267 | 267 | ||
268 | bool VMemo::startRecording() { | 268 | bool VMemo::startRecording() { |
269 | 269 | ||
270 | if ( recording) | 270 | if ( recording) |
271 | return FALSE;; | 271 | return FALSE;; |
272 | Config config( "Vmemo" ); | 272 | Config config( "Vmemo" ); |
273 | config.setGroup( "System" ); | 273 | config.setGroup( "System" ); |
274 | useAlerts = config.readBoolEntry("Alert"); | 274 | useAlerts = config.readBoolEntry("Alert"); |
275 | 275 | ||
276 | // if(useAlerts) | 276 | // if(useAlerts) |
277 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 277 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
278 | // return; | 278 | // return; |
279 | // } else { | 279 | // } else { |
280 | if (!systemZaurus ) | 280 | if (!systemZaurus ) |
281 | QSound::play(Resource::findSound("vmemob")); | 281 | QSound::play(Resource::findSound("vmemob")); |
282 | // } | 282 | // } |
283 | qDebug("Start recording"); | 283 | qDebug("Start recording"); |
284 | recording = TRUE; | 284 | recording = TRUE; |
285 | if (openDSP() == -1) { | 285 | if (openDSP() == -1) { |
286 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 286 | QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
287 | recording = FALSE; | 287 | recording = FALSE; |
288 | return FALSE; | 288 | return FALSE; |
289 | } | 289 | } |
290 | 290 | ||
291 | config.setGroup("Defaults"); | 291 | config.setGroup("Defaults"); |
292 | 292 | ||
293 | QDateTime dt = QDateTime::currentDateTime(); | 293 | QDateTime dt = QDateTime::currentDateTime(); |
294 | 294 | ||
295 | QString fName; | 295 | QString fName; |
296 | config.setGroup( "System" ); | 296 | config.setGroup( "System" ); |
297 | fName = QPEApplication::documentDir() ; | 297 | fName = QPEApplication::documentDir() ; |
298 | fileName = config.readEntry("RecLocation", fName); | 298 | fileName = config.readEntry("RecLocation", fName); |
299 | 299 | ||
300 | int s; | 300 | int s; |
301 | s=fileName.find(':'); | 301 | s=fileName.find(':'); |
302 | if(s) | 302 | if(s) |
303 | fileName=fileName.right(fileName.length()-s-2); | 303 | fileName=fileName.right(fileName.length()-s-2); |
304 | qDebug("filename will be "+fileName); | 304 | qDebug("filename will be "+fileName); |
305 | if( fileName.right(1).find('/') == -1) | 305 | if( fileName.left(1).find('/') == -1) |
306 | fileName+="/"; | 306 | fileName="/"+fileName; |
307 | if( fileName.right(1).find('/') == -1) | ||
308 | fileName+="/"; | ||
307 | fName = "vm_"+ dt.toString()+ ".wav"; | 309 | fName = "vm_"+ dt.toString()+ ".wav"; |
308 | 310 | ||
309 | fileName+=fName; | 311 | fileName+=fName; |
310 | qDebug("filename is "+fileName); | 312 | qDebug("filename is "+fileName); |
311 | // No spaces in the filename | 313 | // No spaces in the filename |
312 | fileName.replace(QRegExp("'"),""); | 314 | fileName.replace(QRegExp("'"),""); |
313 | fileName.replace(QRegExp(" "),"_"); | 315 | fileName.replace(QRegExp(" "),"_"); |
314 | fileName.replace(QRegExp(":"),"."); | 316 | fileName.replace(QRegExp(":"),"."); |
315 | fileName.replace(QRegExp(","),""); | 317 | fileName.replace(QRegExp(","),""); |
316 | 318 | ||
317 | if(openWAV(fileName.latin1()) == -1) { | 319 | if(openWAV(fileName.latin1()) == -1) { |
318 | QString err("Could not open the output file\n"); | 320 | QString err("Could not open the output file\n"); |
319 | err += fileName; | 321 | err += fileName; |
320 | QMessageBox::critical(0, "VMemo", err, "Abort"); | 322 | QMessageBox::critical(0, "VMemo", err, "Abort"); |
321 | close(dsp); | 323 | close(dsp); |
322 | return FALSE; | 324 | return FALSE; |
323 | } | 325 | } |
324 | 326 | ||
325 | QArray<int> cats(1); | 327 | QArray<int> cats(1); |
326 | cats[0] = config.readNumEntry("Category", 0); | 328 | cats[0] = config.readNumEntry("Category", 0); |
327 | 329 | ||
328 | QString dlName("vm_"); | 330 | QString dlName("vm_"); |
329 | dlName += dt.toString(); | 331 | dlName += dt.toString(); |
330 | DocLnk l; | 332 | DocLnk l; |
331 | l.setFile(fileName); | 333 | l.setFile(fileName); |
332 | l.setName(dlName); | 334 | l.setName(dlName); |
333 | l.setType("audio/x-wav"); | 335 | l.setType("audio/x-wav"); |
334 | l.setCategories(cats); | 336 | l.setCategories(cats); |
335 | l.writeLink(); | 337 | l.writeLink(); |
336 | 338 | ||
337 | record(); | 339 | record(); |
338 | return TRUE; | 340 | return TRUE; |
339 | } | 341 | } |
340 | 342 | ||
341 | void VMemo::stopRecording() { | 343 | void VMemo::stopRecording() { |
342 | recording = FALSE; | 344 | recording = FALSE; |
343 | } | 345 | } |
344 | 346 | ||
345 | int VMemo::openDSP() | 347 | int VMemo::openDSP() |
346 | { | 348 | { |
347 | Config cfg("Vmemo"); | 349 | Config cfg("Vmemo"); |
348 | cfg.setGroup("Record"); | 350 | cfg.setGroup("Record"); |
349 | 351 | ||
350 | speed = cfg.readNumEntry("SampleRate", 22050); | 352 | speed = cfg.readNumEntry("SampleRate", 22050); |
351 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 353 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
352 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 354 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
353 | format = AFMT_S16_LE; | 355 | format = AFMT_S16_LE; |
354 | resolution = 16; | 356 | resolution = 16; |
355 | } else { | 357 | } else { |
356 | format = AFMT_U8; | 358 | format = AFMT_U8; |
357 | resolution = 8; | 359 | resolution = 8; |
358 | } | 360 | } |
359 | 361 | ||
360 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 362 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
361 | 363 | ||
362 | if(systemZaurus) { | 364 | if(systemZaurus) { |
363 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 365 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
364 | channels=1; //zaurus has one input channel | 366 | channels=1; //zaurus has one input channel |
365 | } else { | 367 | } else { |
366 | dsp = open("/dev/dsp", O_RDWR); | 368 | dsp = open("/dev/dsp", O_RDWR); |
367 | } | 369 | } |
368 | 370 | ||
369 | if(dsp == -1) { | 371 | if(dsp == -1) { |
370 | perror("open(\"/dev/dsp\")"); | 372 | perror("open(\"/dev/dsp\")"); |