-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 039f3b1..12fb16e 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -1,165 +1,165 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 4 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
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 "playlistwidget.h" | 32 | #include "playlistwidget.h" |
33 | #include "om3u.h" | 33 | #include "om3u.h" |
34 | 34 | ||
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
38 | #include <qpe/mimetype.h> | 38 | #include <qpe/mimetype.h> |
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | 41 | ||
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qcstring.h> | 47 | #include <qcstring.h> |
48 | 48 | ||
49 | //extern PlayListWidget *playList; | 49 | //extern PlayListWidget *playList; |
50 | 50 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
53 | //qDebug("<<<<<<<new m3u "+filePath); | 53 | qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 54 | f.setName(filePath); |
55 | f.open(mode); | 55 | f.open(mode); |
56 | } | 56 | } |
57 | 57 | ||
58 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
59 | 59 | ||
60 | void Om3u::readM3u() { | 60 | void Om3u::readM3u() { |
61 | // qDebug("<<<<<<reading m3u "+f.name()); | 61 | // qDebug("<<<<<<reading m3u "+f.name()); |
62 | QTextStream t(&f); | 62 | QTextStream t(&f); |
63 | QString s; | 63 | QString s; |
64 | while ( !t.atEnd() ) { | 64 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 65 | s=t.readLine(); |
66 | qDebug(s); | 66 | qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 67 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 69 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 70 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 71 | QString name = f.baseName(); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 73 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 74 | append(s); |
75 | // qDebug(s); | 75 | // qDebug(s); |
76 | } else { // is url | 76 | } else { // is url |
77 | s.replace( QRegExp( "%20" )," " ); | 77 | s.replace( QRegExp( "%20" )," " ); |
78 | QString name; | 78 | QString name; |
79 | // if( name.left( 4 ) == "http" ) { | 79 | // if( name.left( 4 ) == "http" ) { |
80 | // name = s.right( s.length() - 7 ); | 80 | // name = s.right( s.length() - 7 ); |
81 | // } else { | 81 | // } else { |
82 | name = s; | 82 | name = s; |
83 | // } | 83 | // } |
84 | append(name); | 84 | append(name); |
85 | // qDebug(name); | 85 | // qDebug(name); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Om3u::readPls() { //it's a pls file | 91 | void Om3u::readPls() { //it's a pls file |
92 | QTextStream t( &f ); | 92 | QTextStream t( &f ); |
93 | QString s; | 93 | QString s; |
94 | while ( !t.atEnd() ) { | 94 | while ( !t.atEnd() ) { |
95 | s = t.readLine(); | 95 | s = t.readLine(); |
96 | if( s.left(4) == "File" ) { | 96 | if( s.left(4) == "File" ) { |
97 | s = s.right( s.length() - 6 ); | 97 | s = s.right( s.length() - 6 ); |
98 | s.replace( QRegExp( "%20" )," "); | 98 | s.replace( QRegExp( "%20" )," "); |
99 | // qDebug( "adding " + s + " to playlist" ); | 99 | // qDebug( "adding " + s + " to playlist" ); |
100 | // numberofentries=2 | 100 | // numberofentries=2 |
101 | // File1=http | 101 | // File1=http |
102 | // Title | 102 | // Title |
103 | // Length | 103 | // Length |
104 | // Version | 104 | // Version |
105 | // File2=http | 105 | // File2=http |
106 | s = s.replace( QRegExp( "\\" ), "/" ); | 106 | s = s.replace( QRegExp( "\\" ), "/" ); |
107 | QFileInfo f( s ); | 107 | QFileInfo f( s ); |
108 | QString name = f.baseName(); | 108 | QString name = f.baseName(); |
109 | if( name.left( 4 ) == "http" ) { | 109 | if( name.left( 4 ) == "http" ) { |
110 | name = s.right( s.length() - 7); | 110 | name = s.right( s.length() - 7); |
111 | } else { | 111 | } else { |
112 | name = s; | 112 | name = s; |
113 | } | 113 | } |
114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
115 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 115 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
116 | append(s); | 116 | append(s); |
117 | else { //if its a url | 117 | else { //if its a url |
118 | if( name.right( 1 ).find( '/' ) == -1) { | 118 | // if( name.right( 1 ).find( '/' ) == -1) { |
119 | s += "/"; | 119 | // s += "/"; |
120 | } | 120 | // } |
121 | append(s); | 121 | append(s); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void Om3u::write() { //writes list to m3u file | 127 | void Om3u::write() { //writes list to m3u file |
128 | QString list; | 128 | QString list; |
129 | if(count()>0) { | 129 | if(count()>0) { |
130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
131 | qDebug(*it); | 131 | qDebug(*it); |
132 | list += *it+"\n"; | 132 | list += *it+"\n"; |
133 | } | 133 | } |
134 | f.writeBlock( list, list.length() ); | 134 | f.writeBlock( list, list.length() ); |
135 | } | 135 | } |
136 | // f.close(); | 136 | // f.close(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void Om3u::add(const QString &filePath) { //adds to m3u file | 139 | void Om3u::add(const QString &filePath) { //adds to m3u file |
140 | append(filePath); | 140 | append(filePath); |
141 | } | 141 | } |
142 | 142 | ||
143 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 143 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
144 | QString list, currentFile; | 144 | QString list, currentFile; |
145 | if(count()>0) { | 145 | if(count()>0) { |
146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
147 | currentFile=*it; | 147 | currentFile=*it; |
148 | // qDebug(*it); | 148 | // qDebug(*it); |
149 | 149 | ||
150 | if( filePath != currentFile) | 150 | if( filePath != currentFile) |
151 | list += currentFile+"\n"; | 151 | list += currentFile+"\n"; |
152 | } | 152 | } |
153 | f.writeBlock( list, list.length() ); | 153 | f.writeBlock( list, list.length() ); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
158 | f.close(); | 158 | f.close(); |
159 | f.remove(); | 159 | f.remove(); |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | void Om3u::close() { //closes m3u file | 163 | void Om3u::close() { //closes m3u file |
164 | f.close(); | 164 | f.close(); |
165 | } | 165 | } |