summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/om3u.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 95ed03c..7149a8e 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -1,164 +1,164 @@
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 "om3u.h" 32#include "om3u.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37 37
38static inline QString fullBaseName ( const QFileInfo &fi ) 38static inline QString fullBaseName ( const QFileInfo &fi )
39{ 39{
40 QString str = fi. fileName ( ); 40 QString str = fi. fileName ( );
41 return str. left ( str. findRev ( '.' )); 41 return str. left ( str. findRev ( '.' ));
42} 42}
43 43
44 44
45//extern PlayListWidget *playList; 45//extern PlayListWidget *playList;
46 46
47Om3u::Om3u( const QString &filePath, int mode) 47Om3u::Om3u( const QString &filePath, int mode)
48 : QStringList (){ 48 : QStringList (){
49//odebug << "<<<<<<<new m3u "+filePath << oendl; 49//odebug << "<<<<<<<new m3u "+filePath << oendl;
50 f.setName(filePath); 50 f.setName(filePath);
51 f.open(mode); 51 f.open(mode);
52} 52}
53 53
54Om3u::~Om3u(){} 54Om3u::~Om3u(){}
55 55
56void Om3u::readM3u() { 56void Om3u::readM3u() {
57// odebug << "<<<<<<reading m3u "+f.name() << oendl; 57// odebug << "<<<<<<reading m3u "+f.name() << oendl;
58 QTextStream t(&f); 58 QTextStream t(&f);
59 t.setEncoding(QTextStream::UnicodeUTF8); 59 t.setEncoding(QTextStream::UnicodeUTF8);
60 QString s; 60 QString s;
61 while ( !t.atEnd() ) { 61 while ( !t.atEnd() ) {
62 s=t.readLine(); 62 s=t.readLine();
63 // odebug << s << oendl; 63 // odebug << s << oendl;
64 if( s.find( "#", 0, TRUE) == -1 ) { 64 if( s.find( "#", 0, TRUE) == -1 ) {
65 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 65 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
66 s = s.right( s.length() -2 ); 66 s = s.right( s.length() -2 );
67 QFileInfo f( s ); 67 QFileInfo f( s );
68 QString name = fullBaseName ( f ); 68 QString name = fullBaseName ( f );
69 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 69 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
70 s=s.replace( QRegExp( "\\" ), "/" ); 70 s=s.replace( QRegExp( "\\" ), "/" );
71 append(s); 71 append(s);
72 // odebug << s << oendl; 72 // odebug << s << oendl;
73 } else { // is url 73 } else { // is url
74 s.replace( QRegExp( "%20" )," " ); 74 s.replace( QRegExp( "%20" )," " );
75 QString name; 75 QString name;
76 // if( name.left( 4 ) == "http" ) { 76 // if( name.left( 4 ) == "http" ) {
77 // name = s.right( s.length() - 7 ); 77 // name = s.right( s.length() - 7 );
78 // } else { 78 // } else {
79 name = s; 79 name = s;
80 // } 80 // }
81 append(name); 81 append(name);
82 // odebug << name << oendl; 82 // odebug << name << oendl;
83 } 83 }
84 } 84 }
85 } 85 }
86} 86}
87 87
88void Om3u::readPls() { //it's a pls file 88void Om3u::readPls() { //it's a pls file
89 QTextStream t( &f ); 89 QTextStream t( &f );
90 t.setEncoding(QTextStream::UnicodeUTF8); 90 t.setEncoding(QTextStream::UnicodeUTF8);
91 QString s; 91 QString s;
92 while ( !t.atEnd() ) { 92 while ( !t.atEnd() ) {
93 s = t.readLine(); 93 s = t.readLine();
94 if( s.left(4) == "File" ) { 94 if( s.left(4) == "File" ) {
95 s = s.right( s.length() - 6 ); 95 s = s.right( s.length() - 6 );
96 s.replace( QRegExp( "%20" )," "); 96 s.replace( QRegExp( "%20" )," ");
97// odebug << "adding " + s + " to playlist" << oendl; 97// odebug << "adding " + s + " to playlist" << oendl;
98 // numberofentries=2 98 // numberofentries=2
99 // File1=http 99 // File1=http
100 // Title 100 // Title
101 // Length 101 // Length
102 // Version 102 // Version
103 // File2=http 103 // File2=http
104 s = s.replace( QRegExp( "\\" ), "/" ); 104 s = s.replace( QRegExp( "\\" ), "/" );
105 QFileInfo f( s ); 105 QFileInfo f( s );
106 QString name = fullBaseName ( f ); 106 QString name = fullBaseName ( f );
107 if( name.left( 4 ) == "http" ) { 107 if( name.left( 4 ) == "http" ) {
108 name = s.right( s.length() - 7); 108 name = s.right( s.length() - 7);
109 } else { 109 } else {
110 name = s; 110 name = s;
111 } 111 }
112 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 112 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
113 if( s.at( s.length() - 4) == '.') // if this is probably a file 113 if( s.at( s.length() - 4) == '.') // if this is probably a file
114 append(s); 114 append(s);
115 else { //if its a url 115 else { //if its a url
116 if( name.right( 1 ).find( '/' ) == -1) { 116 if( name.right( 1 ).find( '/' ) == -1) {
117 s += "/"; 117 s += "/";
118 } 118 }
119 append(s); 119 append(s);
120 } 120 }
121 } 121 }
122 } 122 }
123} 123}
124 124
125void Om3u::write() { //writes list to m3u file 125void Om3u::write() { //writes list to m3u file
126 QString list; 126 QString list;
127 QTextStream t(&f); 127 QTextStream t(&f);
128 t.setEncoding(QTextStream::UnicodeUTF8); 128 t.setEncoding(QTextStream::UnicodeUTF8);
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 // odebug << *it << oendl; 131 // odebug << *it << oendl;
132 t << *it << "\n"; 132 t << *it << "\n";
133 } 133 }
134 } 134 }
135// f.close(); 135// f.close();
136} 136}
137 137
138void Om3u::add(const QString &filePath) { //adds to m3u file 138void Om3u::add(const QString &filePath) { //adds to m3u file
139 append(filePath); 139 append(filePath);
140} 140}
141 141
142void Om3u::remove(const QString &filePath) { //removes from m3u list 142void Om3u::remove(const QString &filePath) { //removes from m3u list
143 QString list, currentFile; 143 QString list, currentFile;
144 if(count()>0) { 144 if(count()>0) {
145 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 145 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
146 currentFile=*it; 146 currentFile=*it;
147 // odebug << *it << oendl; 147 // odebug << *it << oendl;
148 148
149 if( filePath != currentFile) 149 if( filePath != currentFile)
150 list += currentFile+"\n"; 150 list += currentFile+"\n";
151 } 151 }
152 f.writeBlock( list, list.length() ); 152 f.writeBlock( list, list.length() );
153 } 153 }
154} 154}
155 155
156void Om3u::deleteFile(const QString &filePath) {//deletes m3u file 156void Om3u::deleteFile(const QString &) {//deletes m3u file
157 f.close(); 157 f.close();
158 f.remove(); 158 f.remove();
159 159
160} 160}
161 161
162void Om3u::close() { //closes m3u file 162void Om3u::close() { //closes m3u file
163 f.close(); 163 f.close();
164} 164}