author | llornkcor <llornkcor> | 2004-02-09 18:44:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-02-09 18:44:58 (UTC) |
commit | da2559d959567db6a1501e62aa9b2c7c693cc074 (patch) (unidiff) | |
tree | ccbacc2fbed3dab16b0da4c8d1524368d11e40f3 /noncore/multimedia | |
parent | 31fb2e7e1ea652abefc82febbc5739198fa6aaa7 (diff) | |
download | opie-da2559d959567db6a1501e62aa9b2c7c693cc074.zip opie-da2559d959567db6a1501e62aa9b2c7c693cc074.tar.gz opie-da2559d959567db6a1501e62aa9b2c7c693cc074.tar.bz2 |
utf8 patch from Nikita V. Youshchenko <yoush@cs.msu.su>
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 00cfa33..664ec65 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -162,97 +162,97 @@ Lib::~Lib() { | |||
162 | 162 | ||
163 | xine_dispose( m_stream ); | 163 | xine_dispose( m_stream ); |
164 | 164 | ||
165 | xine_exit( m_xine ); | 165 | xine_exit( m_xine ); |
166 | /* FIXME either free or delete but valgrind bitches against both */ | 166 | /* FIXME either free or delete but valgrind bitches against both */ |
167 | //free( m_videoOutput ); | 167 | //free( m_videoOutput ); |
168 | //delete m_audioOutput; | 168 | //delete m_audioOutput; |
169 | } | 169 | } |
170 | 170 | ||
171 | void Lib::resize ( const QSize &s ) { | 171 | void Lib::resize ( const QSize &s ) { |
172 | assert( m_initialized || m_duringInitialization ); | 172 | assert( m_initialized || m_duringInitialization ); |
173 | 173 | ||
174 | if ( s. width ( ) && s. height ( ) ) { | 174 | if ( s. width ( ) && s. height ( ) ) { |
175 | ::null_set_gui_width( m_videoOutput, s. width() ); | 175 | ::null_set_gui_width( m_videoOutput, s. width() ); |
176 | ::null_set_gui_height( m_videoOutput, s. height() ); | 176 | ::null_set_gui_height( m_videoOutput, s. height() ); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | int Lib::majorVersion() { | 180 | int Lib::majorVersion() { |
181 | int major, minor, sub; | 181 | int major, minor, sub; |
182 | xine_get_version ( &major, &minor, &sub ); | 182 | xine_get_version ( &major, &minor, &sub ); |
183 | return major; | 183 | return major; |
184 | } | 184 | } |
185 | 185 | ||
186 | int Lib::minorVersion() { | 186 | int Lib::minorVersion() { |
187 | int major, minor, sub; | 187 | int major, minor, sub; |
188 | xine_get_version ( &major, &minor, &sub ); | 188 | xine_get_version ( &major, &minor, &sub ); |
189 | return minor; | 189 | return minor; |
190 | } | 190 | } |
191 | 191 | ||
192 | int Lib::subVersion() { | 192 | int Lib::subVersion() { |
193 | int major, minor, sub; | 193 | int major, minor, sub; |
194 | xine_get_version ( &major, &minor, &sub ); | 194 | xine_get_version ( &major, &minor, &sub ); |
195 | return sub; | 195 | return sub; |
196 | } | 196 | } |
197 | 197 | ||
198 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 198 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
199 | assert( m_initialized ); | 199 | assert( m_initialized ); |
200 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream | 200 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream |
201 | // but without we get wrong media length reads from libxine for the second media | 201 | // but without we get wrong media length reads from libxine for the second media |
202 | //xine_dispose ( m_stream ); | 202 | //xine_dispose ( m_stream ); |
203 | 203 | ||
204 | QString str = fileName.stripWhiteSpace(); | 204 | QString str = fileName.stripWhiteSpace(); |
205 | 205 | ||
206 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 206 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
207 | //m_queue = xine_event_new_queue (m_stream); | 207 | //m_queue = xine_event_new_queue (m_stream); |
208 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 208 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
209 | 209 | ||
210 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 210 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | return xine_play( m_stream, startPos, start_time); | 213 | return xine_play( m_stream, startPos, start_time); |
214 | } | 214 | } |
215 | 215 | ||
216 | void Lib::stop() { | 216 | void Lib::stop() { |
217 | assert( m_initialized ); | 217 | assert( m_initialized ); |
218 | 218 | ||
219 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 219 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
220 | xine_stop( m_stream ); | 220 | xine_stop( m_stream ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void Lib::pause( bool toggle ) { | 223 | void Lib::pause( bool toggle ) { |
224 | assert( m_initialized ); | 224 | assert( m_initialized ); |
225 | 225 | ||
226 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 226 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
227 | } | 227 | } |
228 | 228 | ||
229 | int Lib::speed() const { | 229 | int Lib::speed() const { |
230 | assert( m_initialized ); | 230 | assert( m_initialized ); |
231 | 231 | ||
232 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 232 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void Lib::setSpeed( int speed ) { | 235 | void Lib::setSpeed( int speed ) { |
236 | assert( m_initialized ); | 236 | assert( m_initialized ); |
237 | 237 | ||
238 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 238 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
239 | } | 239 | } |
240 | 240 | ||
241 | int Lib::status() const { | 241 | int Lib::status() const { |
242 | assert( m_initialized ); | 242 | assert( m_initialized ); |
243 | 243 | ||
244 | return xine_get_status( m_stream ); | 244 | return xine_get_status( m_stream ); |
245 | } | 245 | } |
246 | 246 | ||
247 | int Lib::currentPosition() const { | 247 | int Lib::currentPosition() const { |
248 | assert( m_initialized ); | 248 | assert( m_initialized ); |
249 | 249 | ||
250 | int pos, time, length; | 250 | int pos, time, length; |
251 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 251 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
252 | return pos; | 252 | return pos; |
253 | } | 253 | } |
254 | 254 | ||
255 | int Lib::currentTime() const { | 255 | int Lib::currentTime() const { |
256 | assert( m_initialized ); | 256 | assert( m_initialized ); |
257 | 257 | ||
258 | int pos, time, length; | 258 | int pos, time, length; |
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 7183fb4..69e87e7 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -15,146 +15,149 @@ | |||
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 | t.setEncoding(QTextStream::UnicodeUTF8); |
64 | QString s; | ||
64 | while ( !t.atEnd() ) { | 65 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 66 | s=t.readLine(); |
66 | // qDebug(s); | 67 | // qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 68 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 69 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 70 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 71 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 72 | QString name = f.baseName(); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 73 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 74 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 75 | append(s); |
75 | // qDebug(s); | 76 | // qDebug(s); |
76 | } else { // is url | 77 | } else { // is url |
77 | QString name; | 78 | QString name; |
78 | name = s; | 79 | name = s; |
79 | append(name); | 80 | append(name); |
80 | } | 81 | } |
81 | } | 82 | } |
82 | } | 83 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | void Om3u::readPls() { //it's a pls file | 86 | void Om3u::readPls() { //it's a pls file |
86 | QTextStream t( &f ); | 87 | QTextStream t( &f ); |
87 | QString s; | 88 | t.setEncoding(QTextStream::UnicodeUTF8); |
89 | QString s; | ||
88 | while ( !t.atEnd() ) { | 90 | while ( !t.atEnd() ) { |
89 | s = t.readLine(); | 91 | s = t.readLine(); |
90 | if( s.left(4) == "File" ) { | 92 | if( s.left(4) == "File" ) { |
91 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 93 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
92 | s = s.stripWhiteSpace(); | 94 | s = s.stripWhiteSpace(); |
93 | s.replace( QRegExp( "%20" )," "); | 95 | s.replace( QRegExp( "%20" )," "); |
94 | // qDebug( "adding " + s + " to playlist" ); | 96 | // qDebug( "adding " + s + " to playlist" ); |
95 | // numberofentries=2 | 97 | // numberofentries=2 |
96 | // File1=http | 98 | // File1=http |
97 | // Title | 99 | // Title |
98 | // Length | 100 | // Length |
99 | // Version | 101 | // Version |
100 | // File2=http | 102 | // File2=http |
101 | s = s.replace( QRegExp( "\\" ), "/" ); | 103 | s = s.replace( QRegExp( "\\" ), "/" ); |
102 | QFileInfo f( s ); | 104 | QFileInfo f( s ); |
103 | QString name = f.baseName(); | 105 | QString name = f.baseName(); |
104 | if( name.left( 4 ) == "http" ) { | 106 | if( name.left( 4 ) == "http" ) { |
105 | name = s.right( s.length() - 7); | 107 | name = s.right( s.length() - 7); |
106 | } else { | 108 | } else { |
107 | name = s; | 109 | name = s; |
108 | } | 110 | } |
109 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 111 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
110 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 112 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
111 | append(s); | 113 | append(s); |
112 | else { //if its a url | 114 | else { //if its a url |
113 | // if( name.right( 1 ).find( '/' ) == -1) { | 115 | // if( name.right( 1 ).find( '/' ) == -1) { |
114 | // s += "/"; | 116 | // s += "/"; |
115 | // } | 117 | // } |
116 | append(s); | 118 | append(s); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | } | 121 | } |
120 | } | 122 | } |
121 | 123 | ||
122 | void Om3u::write() { //writes list to m3u file | 124 | void Om3u::write() { //writes list to m3u file |
123 | QString list; | 125 | QString list; |
124 | if(count()>0) { | 126 | QTextStream t(&f); |
127 | t.setEncoding(QTextStream::UnicodeUTF8); | ||
128 | if(count()>0) { | ||
125 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 129 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
126 | // qDebug(*it); | 130 | // qDebug(*it); |
127 | list += *it+"\n"; | 131 | t << *it << "\n"; |
128 | } | 132 | } |
129 | f.writeBlock( list, list.length() ); | ||
130 | } | 133 | } |
131 | // f.close(); | 134 | // f.close(); |
132 | } | 135 | } |
133 | 136 | ||
134 | void Om3u::add(const QString &filePath) { //adds to m3u file | 137 | void Om3u::add(const QString &filePath) { //adds to m3u file |
135 | append(filePath); | 138 | append(filePath); |
136 | } | 139 | } |
137 | 140 | ||
138 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 141 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
139 | QString list, currentFile; | 142 | QString list, currentFile; |
140 | if(count()>0) { | 143 | if(count()>0) { |
141 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 144 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
142 | currentFile=*it; | 145 | currentFile=*it; |
143 | // qDebug(*it); | 146 | // qDebug(*it); |
144 | 147 | ||
145 | if( filePath != currentFile) | 148 | if( filePath != currentFile) |
146 | list += currentFile+"\n"; | 149 | list += currentFile+"\n"; |
147 | } | 150 | } |
148 | f.writeBlock( list, list.length() ); | 151 | f.writeBlock( list, list.length() ); |
149 | } | 152 | } |
150 | } | 153 | } |
151 | 154 | ||
152 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file | 155 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file |
153 | f.close(); | 156 | f.close(); |
154 | f.remove(); | 157 | f.remove(); |
155 | 158 | ||
156 | } | 159 | } |
157 | 160 | ||
158 | void Om3u::close() { //closes m3u file | 161 | void Om3u::close() { //closes m3u file |
159 | f.close(); | 162 | f.close(); |
160 | } | 163 | } |