summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-06-28 11:56:33 (UTC)
committer llornkcor <llornkcor>2004-06-28 11:56:33 (UTC)
commitac6d6947ade0f1bbffa8a4f3b9ac51ca0475f1fb (patch) (unidiff)
tree3087ee37a0bda7bd18c87789236d88d9412d8dde
parent70b610b8e402b0e304238994258664d0e4fbedf6 (diff)
downloadopie-ac6d6947ade0f1bbffa8a4f3b9ac51ca0475f1fb.zip
opie-ac6d6947ade0f1bbffa8a4f3b9ac51ca0475f1fb.tar.gz
opie-ac6d6947ade0f1bbffa8a4f3b9ac51ca0475f1fb.tar.bz2
remove dots in name
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index 360b884..80453e1 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -1,120 +1,120 @@
1//wavFile.cpp 1//wavFile.cpp
2#include "wavFile.h" 2#include "wavFile.h"
3#include "qtrec.h" 3#include "qtrec.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <qpe/config.h> 7#include <qpe/config.h>
8using namespace Opie::Core; 8using namespace Opie::Core;
9 9
10/* QT */ 10/* QT */
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <qdir.h> 12#include <qdir.h>
13 13
14/* STD */ 14/* STD */
15#include <errno.h> 15#include <errno.h>
16#include <sys/time.h> 16#include <sys/time.h>
17#include <sys/types.h> 17#include <sys/types.h>
18#include <sys/vfs.h> 18#include <sys/vfs.h>
19#include <fcntl.h> 19#include <fcntl.h>
20#include <math.h> 20#include <math.h>
21#include <mntent.h> 21#include <mntent.h>
22#include <stdio.h> 22#include <stdio.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25 25
26WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, 26WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate,
27 int channels, int resolution, int format ) 27 int channels, int resolution, int format )
28 : QObject( parent) 28 : QObject( parent)
29{ 29{
30//odebug << "new wave file" << oendl; 30//odebug << "new wave file" << oendl;
31 bool b = makeNwFile; 31 bool b = makeNwFile;
32 wavSampleRate=sampleRate; 32 wavSampleRate=sampleRate;
33 wavFormat=format; 33 wavFormat=format;
34 wavChannels=channels; 34 wavChannels=channels;
35 wavResolution=resolution; 35 wavResolution=resolution;
36 useTmpFile=false; 36 useTmpFile=false;
37 if( b) { 37 if( b) {
38 newFile(); 38 newFile();
39 } else { 39 } else {
40 openFile(fileName); 40 openFile(fileName);
41 } 41 }
42} 42}
43 43
44bool WavFile::newFile() { 44bool WavFile::newFile() {
45 45
46// odebug << "Set up new file" << oendl; 46// odebug << "Set up new file" << oendl;
47 Config cfg("OpieRec"); 47 Config cfg("OpieRec");
48 cfg.setGroup("Settings"); 48 cfg.setGroup("Settings");
49 49
50 currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); 50 currentFileName=cfg.readEntry("directory",QDir::homeDirPath());
51 QString date; 51 QString date;
52 QDateTime dt = QDateTime::currentDateTime(); 52 QDateTime dt = QDateTime::currentDateTime();
53 date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true); 53 date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true);
54 date.replace(QRegExp("'"),""); 54 date.replace(QRegExp("'"),"");
55 date.replace(QRegExp(" "),"_"); 55 date.replace(QRegExp(" "),"_");
56 date.replace(QRegExp(":"),"."); 56 date.replace(QRegExp(":"),"-");
57 date.replace(QRegExp(","),""); 57 date.replace(QRegExp(","),"");
58 58
59 QString currentFile=date; 59 QString currentFile=date;
60 if(currentFileName.right(1).find("/",0,true) == -1) 60 if(currentFileName.right(1).find("/",0,true) == -1)
61 currentFileName += "/" + date; 61 currentFileName += "/" + date;
62 else 62 else
63 currentFileName += date; 63 currentFileName += date;
64 currentFileName+=".wav"; 64 currentFileName+=".wav";
65 65
66// odebug << "set up file for recording: "+currentFileName << oendl; 66// odebug << "set up file for recording: "+currentFileName << oendl;
67 char pointer[] = "/tmp/opierec-XXXXXX"; 67 char pointer[] = "/tmp/opierec-XXXXXX";
68 int fd = 0; 68 int fd = 0;
69 69
70 if( currentFileName.find("/mnt",0,true) == -1 70 if( currentFileName.find("/mnt",0,true) == -1
71 && currentFileName.find("/tmp",0,true) == -1 ) { 71 && currentFileName.find("/tmp",0,true) == -1 ) {
72 // if destination file is most likely in flash (assuming jffs2) 72 // if destination file is most likely in flash (assuming jffs2)
73 // we have to write to a different filesystem first 73 // we have to write to a different filesystem first
74 74
75 useTmpFile = true; 75 useTmpFile = true;
76 if(( fd = mkstemp( pointer)) < 0 ) { 76 if(( fd = mkstemp( pointer)) < 0 ) {
77 perror("mkstemp failed"); 77 perror("mkstemp failed");
78 return false; 78 return false;
79 } 79 }
80 80
81// odebug << "Opening tmp file " << pointer << "" << oendl; 81// odebug << "Opening tmp file " << pointer << "" << oendl;
82 track.setName( pointer); 82 track.setName( pointer);
83 83
84 } else { //just use regular file.. no moving 84 } else { //just use regular file.. no moving
85 85
86 useTmpFile = false; 86 useTmpFile = false;
87 track.setName( currentFileName); 87 track.setName( currentFileName);
88 } 88 }
89 if(!track.open( IO_ReadWrite | IO_Truncate)) { 89 if(!track.open( IO_ReadWrite | IO_Truncate)) {
90 QString errorMsg=(QString)strerror(errno); 90 QString errorMsg=(QString)strerror(errno);
91 odebug << errorMsg << oendl; 91 odebug << errorMsg << oendl;
92 QMessageBox::message("Note", "Error opening file.\n" +errorMsg); 92 QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
93 93
94 return false; 94 return false;
95 } else { 95 } else {
96 setWavHeader( track.handle() , &hdr); 96 setWavHeader( track.handle() , &hdr);
97 } 97 }
98return true; 98return true;
99} 99}
100 100
101WavFile::~WavFile() { 101WavFile::~WavFile() {
102 102
103 closeFile(); 103 closeFile();
104} 104}
105 105
106void WavFile::closeFile() { 106void WavFile::closeFile() {
107 if(track.isOpen()) 107 if(track.isOpen())
108 track.close(); 108 track.close();
109} 109}
110 110
111int WavFile::openFile(const QString &currentFileName) { 111int WavFile::openFile(const QString &currentFileName) {
112// odebug << "open play file "+currentFileName << oendl; 112// odebug << "open play file "+currentFileName << oendl;
113 closeFile(); 113 closeFile();
114 114
115 track.setName(currentFileName); 115 track.setName(currentFileName);
116 116
117 if(!track.open(IO_ReadOnly)) { 117 if(!track.open(IO_ReadOnly)) {
118 QString errorMsg=(QString)strerror(errno); 118 QString errorMsg=(QString)strerror(errno);
119 odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; 119 odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl;
120 QMessageBox::message("Note", "Error opening file.\n" +errorMsg); 120 QMessageBox::message("Note", "Error opening file.\n" +errorMsg);