author | llornkcor <llornkcor> | 2004-06-27 22:57:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-06-27 22:57:58 (UTC) |
commit | 8aacad28f7906452f6e410f81b286430d43a0eb3 (patch) (unidiff) | |
tree | 7ad01098a73a9d45b621af2aec03bdba3091d90a | |
parent | 78cd13f15c6057e18b6f095841a90bb438dd6fd2 (diff) | |
download | opie-8aacad28f7906452f6e410f81b286430d43a0eb3.zip opie-8aacad28f7906452f6e410f81b286430d43a0eb3.tar.gz opie-8aacad28f7906452f6e410f81b286430d43a0eb3.tar.bz2 |
replace dots in filename
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index f088bef..b80b378 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -218,193 +218,193 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
218 | // else | 218 | // else |
219 | systemZaurus = FALSE; | 219 | systemZaurus = FALSE; |
220 | 220 | ||
221 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 221 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
224 | 224 | ||
225 | if( toggleKey != -1 ) { | 225 | if( toggleKey != -1 ) { |
226 | odebug << "Register key " << toggleKey << "" << oendl; | 226 | odebug << "Register key " << toggleKey << "" << oendl; |
227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
228 | // e << 4096; // Key_Escape | 228 | // e << 4096; // Key_Escape |
229 | // e << Key_F5; //4148 | 229 | // e << Key_F5; //4148 |
230 | e << toggleKey; | 230 | e << toggleKey; |
231 | e << QString("QPE/VMemo"); | 231 | e << QString("QPE/VMemo"); |
232 | e << QString("toggleRecord()"); | 232 | e << QString("toggleRecord()"); |
233 | } | 233 | } |
234 | if(toggleKey == 1) | 234 | if(toggleKey == 1) |
235 | usingIcon = TRUE; | 235 | usingIcon = TRUE; |
236 | else | 236 | else |
237 | usingIcon = FALSE; | 237 | usingIcon = FALSE; |
238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) | 238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | // hide(); | 239 | // hide(); |
240 | recording = FALSE; | 240 | recording = FALSE; |
241 | // } | 241 | // } |
242 | } | 242 | } |
243 | 243 | ||
244 | VMemo::~VMemo() { | 244 | VMemo::~VMemo() { |
245 | } | 245 | } |
246 | 246 | ||
247 | int VMemo::position() | 247 | int VMemo::position() |
248 | { | 248 | { |
249 | return 6; | 249 | return 6; |
250 | } | 250 | } |
251 | 251 | ||
252 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 252 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
253 | odebug << "Vmemo receive" << oendl; | 253 | odebug << "Vmemo receive" << oendl; |
254 | QDataStream stream( data, IO_ReadOnly ); | 254 | QDataStream stream( data, IO_ReadOnly ); |
255 | 255 | ||
256 | if (msg == "toggleRecord()") { | 256 | if (msg == "toggleRecord()") { |
257 | if (recording) { | 257 | if (recording) { |
258 | fromToggle = TRUE; | 258 | fromToggle = TRUE; |
259 | stopRecording(); | 259 | stopRecording(); |
260 | } else { | 260 | } else { |
261 | fromToggle = TRUE; | 261 | fromToggle = TRUE; |
262 | startRecording(); | 262 | startRecording(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | void VMemo::paintEvent( QPaintEvent* ) { | 267 | void VMemo::paintEvent( QPaintEvent* ) { |
268 | QPainter p(this); | 268 | QPainter p(this); |
269 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 269 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { | 272 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { |
273 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 273 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
274 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 274 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
275 | 275 | ||
276 | // if (!systemZaurus && me != NULL) | 276 | // if (!systemZaurus && me != NULL) |
277 | // return; | 277 | // return; |
278 | // } | 278 | // } |
279 | 279 | ||
280 | if(!recording) | 280 | if(!recording) |
281 | startRecording(); | 281 | startRecording(); |
282 | else | 282 | else |
283 | stopRecording(); | 283 | stopRecording(); |
284 | } | 284 | } |
285 | 285 | ||
286 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 286 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
287 | } | 287 | } |
288 | 288 | ||
289 | bool VMemo::startRecording() { | 289 | bool VMemo::startRecording() { |
290 | Config config( "Vmemo" ); | 290 | Config config( "Vmemo" ); |
291 | config.setGroup( "System" ); | 291 | config.setGroup( "System" ); |
292 | 292 | ||
293 | useAlerts = config.readBoolEntry("Alert",1); | 293 | useAlerts = config.readBoolEntry("Alert",1); |
294 | if(useAlerts) { | 294 | if(useAlerts) { |
295 | 295 | ||
296 | msgLabel = new QLabel( 0, "alertLabel" ); | 296 | msgLabel = new QLabel( 0, "alertLabel" ); |
297 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 297 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
298 | msgLabel->show(); | 298 | msgLabel->show(); |
299 | } | 299 | } |
300 | 300 | ||
301 | odebug << "Start recording engines" << oendl; | 301 | odebug << "Start recording engines" << oendl; |
302 | recording = TRUE; | 302 | recording = TRUE; |
303 | 303 | ||
304 | if (openDSP() == -1) { | 304 | if (openDSP() == -1) { |
305 | recording = FALSE; | 305 | recording = FALSE; |
306 | return FALSE; | 306 | return FALSE; |
307 | } | 307 | } |
308 | 308 | ||
309 | config.setGroup("Defaults"); | 309 | config.setGroup("Defaults"); |
310 | 310 | ||
311 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 311 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
312 | date.replace(QRegExp("'"),""); | 312 | date.replace(QRegExp("'"),""); |
313 | date.replace(QRegExp(" "),"_"); | 313 | date.replace(QRegExp(" "),"_"); |
314 | date.replace(QRegExp(":"),"."); | 314 | date.replace(QRegExp(":"),"-"); |
315 | date.replace(QRegExp(","),""); | 315 | date.replace(QRegExp(","),""); |
316 | 316 | ||
317 | QString fName; | 317 | QString fName; |
318 | config.setGroup( "System" ); | 318 | config.setGroup( "System" ); |
319 | fName = QPEApplication::documentDir() ; | 319 | fName = QPEApplication::documentDir() ; |
320 | fileName = config.readEntry("RecLocation", fName); | 320 | fileName = config.readEntry("RecLocation", fName); |
321 | 321 | ||
322 | int s; | 322 | int s; |
323 | s=fileName.find(':'); | 323 | s=fileName.find(':'); |
324 | if(s) | 324 | if(s) |
325 | fileName=fileName.right(fileName.length()-s-2); | 325 | fileName=fileName.right(fileName.length()-s-2); |
326 | odebug << "pathname will be "+fileName << oendl; | 326 | odebug << "pathname will be "+fileName << oendl; |
327 | 327 | ||
328 | if( fileName.left(1).find('/') == -1) | 328 | if( fileName.left(1).find('/') == -1) |
329 | fileName="/"+fileName; | 329 | fileName="/"+fileName; |
330 | if( fileName.right(1).find('/') == -1) | 330 | if( fileName.right(1).find('/') == -1) |
331 | fileName+="/"; | 331 | fileName+="/"; |
332 | fName = "vm_"+ date + ".wav"; | 332 | fName = "vm_"+ date + ".wav"; |
333 | 333 | ||
334 | fileName+=fName; | 334 | fileName+=fName; |
335 | odebug << "filename is " + fileName << oendl; | 335 | odebug << "filename is " + fileName << oendl; |
336 | // open tmp file here | 336 | // open tmp file here |
337 | char *pointer; | 337 | char *pointer; |
338 | pointer=tmpnam(NULL); | 338 | pointer=tmpnam(NULL); |
339 | odebug << "Opening tmp file " << pointer << "" << oendl; | 339 | odebug << "Opening tmp file " << pointer << "" << oendl; |
340 | 340 | ||
341 | if(openWAV(pointer ) == -1) { | 341 | if(openWAV(pointer ) == -1) { |
342 | 342 | ||
343 | QString err("Could not open the temp file\n"); | 343 | QString err("Could not open the temp file\n"); |
344 | err += fileName; | 344 | err += fileName; |
345 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 345 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
346 | ::close(dsp); | 346 | ::close(dsp); |
347 | return FALSE; | 347 | return FALSE; |
348 | } | 348 | } |
349 | if( record() ) { | 349 | if( record() ) { |
350 | 350 | ||
351 | QString cmd; | 351 | QString cmd; |
352 | if( fileName.find(".wav",0,TRUE) == -1) | 352 | if( fileName.find(".wav",0,TRUE) == -1) |
353 | fileName += ".wav"; | 353 | fileName += ".wav"; |
354 | 354 | ||
355 | cmd.sprintf("mv %s "+fileName, pointer); | 355 | cmd.sprintf("mv %s "+fileName, pointer); |
356 | // move tmp file to regular file here | 356 | // move tmp file to regular file here |
357 | 357 | ||
358 | system(cmd.latin1()); | 358 | system(cmd.latin1()); |
359 | 359 | ||
360 | QArray<int> cats(1); | 360 | QArray<int> cats(1); |
361 | cats[0] = config.readNumEntry("Category", 0); | 361 | cats[0] = config.readNumEntry("Category", 0); |
362 | 362 | ||
363 | QString dlName("vm_"); | 363 | QString dlName("vm_"); |
364 | dlName += date; | 364 | dlName += date; |
365 | DocLnk l; | 365 | DocLnk l; |
366 | l.setFile(fileName); | 366 | l.setFile(fileName); |
367 | l.setName(dlName); | 367 | l.setName(dlName); |
368 | l.setType("audio/x-wav"); | 368 | l.setType("audio/x-wav"); |
369 | l.setCategories(cats); | 369 | l.setCategories(cats); |
370 | l.writeLink(); | 370 | l.writeLink(); |
371 | return TRUE; | 371 | return TRUE; |
372 | } else | 372 | } else |
373 | return FALSE; | 373 | return FALSE; |
374 | 374 | ||
375 | } | 375 | } |
376 | 376 | ||
377 | void VMemo::stopRecording() { | 377 | void VMemo::stopRecording() { |
378 | show(); | 378 | show(); |
379 | odebug << "Stopped recording" << oendl; | 379 | odebug << "Stopped recording" << oendl; |
380 | recording = FALSE; | 380 | recording = FALSE; |
381 | if(useAlerts) { | 381 | if(useAlerts) { |
382 | msgLabel->close(); | 382 | msgLabel->close(); |
383 | msgLabel=0; | 383 | msgLabel=0; |
384 | delete msgLabel; | 384 | delete msgLabel; |
385 | } | 385 | } |
386 | t_timer->stop(); | 386 | t_timer->stop(); |
387 | Config cfg("Vmemo"); | 387 | Config cfg("Vmemo"); |
388 | cfg.setGroup("Defaults"); | 388 | cfg.setGroup("Defaults"); |
389 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) | 389 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) |
390 | // hide(); | 390 | // hide(); |
391 | } | 391 | } |
392 | 392 | ||
393 | int VMemo::openDSP() { | 393 | int VMemo::openDSP() { |
394 | Config cfg("Vmemo"); | 394 | Config cfg("Vmemo"); |
395 | cfg.setGroup("Record"); | 395 | cfg.setGroup("Record"); |
396 | 396 | ||
397 | speed = cfg.readNumEntry("SampleRate", 22050); | 397 | speed = cfg.readNumEntry("SampleRate", 22050); |
398 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 398 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
399 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 399 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
400 | format = AFMT_S16_LE; | 400 | format = AFMT_S16_LE; |
401 | resolution = 16; | 401 | resolution = 16; |
402 | } else { | 402 | } else { |
403 | format = AFMT_U8; | 403 | format = AFMT_U8; |
404 | resolution = 8; | 404 | resolution = 8; |
405 | } | 405 | } |
406 | 406 | ||
407 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; | 407 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
408 | 408 | ||
409 | if(systemZaurus) { | 409 | if(systemZaurus) { |
410 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 410 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |