Diffstat (limited to 'core/multimedia/opieplayer/om3u.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index ae89518..95ed03c 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -22,86 +22,88 @@ | |||
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "om3u.h" | 32 | #include "om3u.h" |
33 | 33 | ||
34 | /* OPIE */ | ||
35 | #include <opie2/odebug.h> | ||
34 | 36 | ||
35 | 37 | ||
36 | static inline QString fullBaseName ( const QFileInfo &fi ) | 38 | static inline QString fullBaseName ( const QFileInfo &fi ) |
37 | { | 39 | { |
38 | QString str = fi. fileName ( ); | 40 | QString str = fi. fileName ( ); |
39 | return str. left ( str. findRev ( '.' )); | 41 | return str. left ( str. findRev ( '.' )); |
40 | } | 42 | } |
41 | 43 | ||
42 | 44 | ||
43 | //extern PlayListWidget *playList; | 45 | //extern PlayListWidget *playList; |
44 | 46 | ||
45 | Om3u::Om3u( const QString &filePath, int mode) | 47 | Om3u::Om3u( const QString &filePath, int mode) |
46 | : QStringList (){ | 48 | : QStringList (){ |
47 | //qDebug("<<<<<<<new m3u "+filePath); | 49 | //odebug << "<<<<<<<new m3u "+filePath << oendl; |
48 | f.setName(filePath); | 50 | f.setName(filePath); |
49 | f.open(mode); | 51 | f.open(mode); |
50 | } | 52 | } |
51 | 53 | ||
52 | Om3u::~Om3u(){} | 54 | Om3u::~Om3u(){} |
53 | 55 | ||
54 | void Om3u::readM3u() { | 56 | void Om3u::readM3u() { |
55 | // qDebug("<<<<<<reading m3u "+f.name()); | 57 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; |
56 | QTextStream t(&f); | 58 | QTextStream t(&f); |
57 | t.setEncoding(QTextStream::UnicodeUTF8); | 59 | t.setEncoding(QTextStream::UnicodeUTF8); |
58 | QString s; | 60 | QString s; |
59 | while ( !t.atEnd() ) { | 61 | while ( !t.atEnd() ) { |
60 | s=t.readLine(); | 62 | s=t.readLine(); |
61 | // qDebug(s); | 63 | // odebug << s << oendl; |
62 | if( s.find( "#", 0, TRUE) == -1 ) { | 64 | if( s.find( "#", 0, TRUE) == -1 ) { |
63 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 65 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
64 | s = s.right( s.length() -2 ); | 66 | s = s.right( s.length() -2 ); |
65 | QFileInfo f( s ); | 67 | QFileInfo f( s ); |
66 | QString name = fullBaseName ( f ); | 68 | QString name = fullBaseName ( f ); |
67 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 69 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
68 | s=s.replace( QRegExp( "\\" ), "/" ); | 70 | s=s.replace( QRegExp( "\\" ), "/" ); |
69 | append(s); | 71 | append(s); |
70 | // qDebug(s); | 72 | // odebug << s << oendl; |
71 | } else { // is url | 73 | } else { // is url |
72 | s.replace( QRegExp( "%20" )," " ); | 74 | s.replace( QRegExp( "%20" )," " ); |
73 | QString name; | 75 | QString name; |
74 | // if( name.left( 4 ) == "http" ) { | 76 | // if( name.left( 4 ) == "http" ) { |
75 | // name = s.right( s.length() - 7 ); | 77 | // name = s.right( s.length() - 7 ); |
76 | // } else { | 78 | // } else { |
77 | name = s; | 79 | name = s; |
78 | // } | 80 | // } |
79 | append(name); | 81 | append(name); |
80 | // qDebug(name); | 82 | // odebug << name << oendl; |
81 | } | 83 | } |
82 | } | 84 | } |
83 | } | 85 | } |
84 | } | 86 | } |
85 | 87 | ||
86 | void Om3u::readPls() { //it's a pls file | 88 | void Om3u::readPls() { //it's a pls file |
87 | QTextStream t( &f ); | 89 | QTextStream t( &f ); |
88 | t.setEncoding(QTextStream::UnicodeUTF8); | 90 | t.setEncoding(QTextStream::UnicodeUTF8); |
89 | QString s; | 91 | QString s; |
90 | while ( !t.atEnd() ) { | 92 | while ( !t.atEnd() ) { |
91 | s = t.readLine(); | 93 | s = t.readLine(); |
92 | if( s.left(4) == "File" ) { | 94 | if( s.left(4) == "File" ) { |
93 | s = s.right( s.length() - 6 ); | 95 | s = s.right( s.length() - 6 ); |
94 | s.replace( QRegExp( "%20" )," "); | 96 | s.replace( QRegExp( "%20" )," "); |
95 | // qDebug( "adding " + s + " to playlist" ); | 97 | // odebug << "adding " + s + " to playlist" << oendl; |
96 | // numberofentries=2 | 98 | // numberofentries=2 |
97 | // File1=http | 99 | // File1=http |
98 | // Title | 100 | // Title |
99 | // Length | 101 | // Length |
100 | // Version | 102 | // Version |
101 | // File2=http | 103 | // File2=http |
102 | s = s.replace( QRegExp( "\\" ), "/" ); | 104 | s = s.replace( QRegExp( "\\" ), "/" ); |
103 | QFileInfo f( s ); | 105 | QFileInfo f( s ); |
104 | QString name = fullBaseName ( f ); | 106 | QString name = fullBaseName ( f ); |
105 | if( name.left( 4 ) == "http" ) { | 107 | if( name.left( 4 ) == "http" ) { |
106 | name = s.right( s.length() - 7); | 108 | name = s.right( s.length() - 7); |
107 | } else { | 109 | } else { |
@@ -113,46 +115,46 @@ void Om3u::readPls() { //it's a pls file | |||
113 | else { //if its a url | 115 | else { //if its a url |
114 | if( name.right( 1 ).find( '/' ) == -1) { | 116 | if( name.right( 1 ).find( '/' ) == -1) { |
115 | s += "/"; | 117 | s += "/"; |
116 | } | 118 | } |
117 | append(s); | 119 | append(s); |
118 | } | 120 | } |
119 | } | 121 | } |
120 | } | 122 | } |
121 | } | 123 | } |
122 | 124 | ||
123 | void Om3u::write() { //writes list to m3u file | 125 | void Om3u::write() { //writes list to m3u file |
124 | QString list; | 126 | QString list; |
125 | QTextStream t(&f); | 127 | QTextStream t(&f); |
126 | t.setEncoding(QTextStream::UnicodeUTF8); | 128 | t.setEncoding(QTextStream::UnicodeUTF8); |
127 | if(count()>0) { | 129 | if(count()>0) { |
128 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
129 | // qDebug(*it); | 131 | // odebug << *it << oendl; |
130 | t << *it << "\n"; | 132 | t << *it << "\n"; |
131 | } | 133 | } |
132 | } | 134 | } |
133 | // f.close(); | 135 | // f.close(); |
134 | } | 136 | } |
135 | 137 | ||
136 | void Om3u::add(const QString &filePath) { //adds to m3u file | 138 | void Om3u::add(const QString &filePath) { //adds to m3u file |
137 | append(filePath); | 139 | append(filePath); |
138 | } | 140 | } |
139 | 141 | ||
140 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 142 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
141 | QString list, currentFile; | 143 | QString list, currentFile; |
142 | if(count()>0) { | 144 | if(count()>0) { |
143 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 145 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
144 | currentFile=*it; | 146 | currentFile=*it; |
145 | // qDebug(*it); | 147 | // odebug << *it << oendl; |
146 | 148 | ||
147 | if( filePath != currentFile) | 149 | if( filePath != currentFile) |
148 | list += currentFile+"\n"; | 150 | list += currentFile+"\n"; |
149 | } | 151 | } |
150 | f.writeBlock( list, list.length() ); | 152 | f.writeBlock( list, list.length() ); |
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
154 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 156 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
155 | f.close(); | 157 | f.close(); |
156 | f.remove(); | 158 | f.remove(); |
157 | 159 | ||
158 | } | 160 | } |