summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-14 06:05:13 (UTC)
committer schurig <schurig>2003-06-14 06:05:13 (UTC)
commit6b57a9fbe9f56e6af3911ea9337872c468b614b5 (patch) (unidiff)
tree69ef7f20babceda2ba3ee8138cbd29bdd8587f46
parentbbb4e35556d1d1a759dbe99bc155ecfc45e49c1b (diff)
downloadopie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.zip
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.gz
opie-6b57a9fbe9f56e6af3911ea9337872c468b614b5.tar.bz2
Adaptions for QT_QWS_DEVFS
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp15
-rw-r--r--core/multimedia/opieplayer/libflash/libflashplugin.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp6
3 files changed, 21 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index d01d2ba..6a38fc9 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -1,313 +1,322 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20// L.J.Potter added better error code Fri 02-15-2002 14:37:47 20// L.J.Potter added better error code Fri 02-15-2002 14:37:47
21 21
22 22
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28 28
29#include "audiodevice.h" 29#include "audiodevice.h"
30 30
31 31
32#include <errno.h> 32#include <errno.h>
33 33
34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
35#include "qpe/qcopenvelope_qws.h" 35#include "qpe/qcopenvelope_qws.h"
36#endif 36#endif
37 37
38#if defined(Q_WS_X11) || defined(Q_WS_QWS) 38#if defined(Q_WS_X11) || defined(Q_WS_QWS)
39#include <fcntl.h> 39#include <fcntl.h>
40#include <sys/ioctl.h> 40#include <sys/ioctl.h>
41#include <sys/soundcard.h> 41#include <sys/soundcard.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43#include <sys/time.h> 43#include <sys/time.h>
44#include <sys/types.h> 44#include <sys/types.h>
45#include <unistd.h> 45#include <unistd.h>
46#endif 46#endif
47 47
48# if defined(QT_QWS_IPAQ) 48# if defined(QT_QWS_IPAQ)
49static const int sound_fragment_shift = 14; 49static const int sound_fragment_shift = 14;
50# else 50# else
51static const int sound_fragment_shift = 16; 51static const int sound_fragment_shift = 16;
52# endif 52# endif
53static const int sound_fragment_bytes = (1<<sound_fragment_shift); 53static const int sound_fragment_bytes = (1<<sound_fragment_shift);
54//#endif 54//#endif
55 55
56 56
57class AudioDevicePrivate { 57class AudioDevicePrivate {
58public: 58public:
59 int handle; 59 int handle;
60 unsigned int frequency; 60 unsigned int frequency;
61 unsigned int channels; 61 unsigned int channels;
62 unsigned int bytesPerSample; 62 unsigned int bytesPerSample;
63 unsigned int bufferSize; 63 unsigned int bufferSize;
64//#ifndef Q_OS_WIN32 64//#ifndef Q_OS_WIN32
65 bool can_GETOSPACE; 65 bool can_GETOSPACE;
66 char* unwrittenBuffer; 66 char* unwrittenBuffer;
67 unsigned int unwritten; 67 unsigned int unwritten;
68//#endif 68//#endif
69 69
70 static int dspFd; 70 static int dspFd;
71 static bool muted; 71 static bool muted;
72 static unsigned int leftVolume; 72 static unsigned int leftVolume;
73 static unsigned int rightVolume; 73 static unsigned int rightVolume;
74}; 74};
75 75
76 76
77#ifdef Q_WS_QWS 77#ifdef Q_WS_QWS
78// This is for keeping the device open in-between playing files when 78// This is for keeping the device open in-between playing files when
79// the device makes clicks and it starts to drive you insane! :) 79// the device makes clicks and it starts to drive you insane! :)
80// Best to have the device not open when not using it though 80// Best to have the device not open when not using it though
81//#define KEEP_DEVICE_OPEN 81//#define KEEP_DEVICE_OPEN
82#endif 82#endif
83 83
84 84
85int AudioDevicePrivate::dspFd = 0; 85int AudioDevicePrivate::dspFd = 0;
86bool AudioDevicePrivate::muted = FALSE; 86bool AudioDevicePrivate::muted = FALSE;
87unsigned int AudioDevicePrivate::leftVolume = 0; 87unsigned int AudioDevicePrivate::leftVolume = 0;
88unsigned int AudioDevicePrivate::rightVolume = 0; 88unsigned int AudioDevicePrivate::rightVolume = 0;
89 89
90 90
91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
92 muted = AudioDevicePrivate::muted; 92 muted = AudioDevicePrivate::muted;
93 unsigned int volume; 93 unsigned int volume;
94#ifdef QT_QWS_DEVFS
95 int mixerHandle = open( "/dev/sound/mixer", O_RDWR );
96#else
94 int mixerHandle = open( "/dev/mixer", O_RDWR ); 97 int mixerHandle = open( "/dev/mixer", O_RDWR );
98#endif
95 if ( mixerHandle >= 0 ) { 99 if ( mixerHandle >= 0 ) {
96 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 100 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
97 perror("ioctl(\"MIXER_READ\")"); 101 perror("ioctl(\"MIXER_READ\")");
98 close( mixerHandle ); 102 close( mixerHandle );
99 } else 103 } else
100 perror("open(\"/dev/mixer\")"); 104 perror("open(\"/dev/mixer\")");
101 leftVolume = ((volume & 0x00FF) << 16) / 101; 105 leftVolume = ((volume & 0x00FF) << 16) / 101;
102 rightVolume = ((volume & 0xFF00) << 8) / 101; 106 rightVolume = ((volume & 0xFF00) << 8) / 101;
103} 107}
104 108
105 109
106void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 110void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
107 AudioDevicePrivate::muted = muted; 111 AudioDevicePrivate::muted = muted;
108 if ( muted ) { 112 if ( muted ) {
109 AudioDevicePrivate::leftVolume = leftVolume; 113 AudioDevicePrivate::leftVolume = leftVolume;
110 AudioDevicePrivate::rightVolume = rightVolume; 114 AudioDevicePrivate::rightVolume = rightVolume;
111 leftVolume = 0; 115 leftVolume = 0;
112 rightVolume = 0; 116 rightVolume = 0;
113 } else { 117 } else {
114 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 118 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
115 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 119 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
116 } 120 }
117 // Volume can be from 0 to 100 which is 101 distinct values 121 // Volume can be from 0 to 100 which is 101 distinct values
118 unsigned int rV = (rightVolume * 101) >> 16; 122 unsigned int rV = (rightVolume * 101) >> 16;
119 123
120# if 0 124# if 0
121 unsigned int lV = (leftVolume * 101) >> 16; 125 unsigned int lV = (leftVolume * 101) >> 16;
122 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 126 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
123 int mixerHandle = 0; 127 int mixerHandle = 0;
128#ifdef QT_QWS_DEVFS
129 if ( ( mixerHandle = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
130#else
124 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 131 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
132#endif
125 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) 133 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
126 perror("ioctl(\"MIXER_WRITE\")"); 134 perror("ioctl(\"MIXER_WRITE\")");
127 close( mixerHandle ); 135 close( mixerHandle );
128 } else 136 } else
129 perror("open(\"/dev/mixer\")"); 137 perror("open(\"/dev/mixer\")");
130 138
131# else 139# else
132 // This is the way this has to be done now I guess, doesn't allow for 140 // This is the way this has to be done now I guess, doesn't allow for
133 // independant right and left channel setting, or setting for different outputs 141 // independant right and left channel setting, or setting for different outputs
134 Config cfg("qpe"); // qtopia is "Sound" 142 Config cfg("qpe"); // qtopia is "Sound"
135 cfg.setGroup("Volume"); // qtopia is "Settings" 143 cfg.setGroup("Volume"); // qtopia is "Settings"
136 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume 144 cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
137# endif 145# endif
138 146
139//#endif 147//#endif
140// qDebug( "setting volume to: 0x%x", volume ); 148// qDebug( "setting volume to: 0x%x", volume );
141#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 149#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
142 // Send notification that the volume has changed 150 // Send notification that the volume has changed
143 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 151 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
144#endif 152#endif
145} 153}
146 154
147 155
148 156
149AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 157AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
150 // qDebug("creating new audio device"); 158 // qDebug("creating new audio device");
151// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 159// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
152 d = new AudioDevicePrivate; 160 d = new AudioDevicePrivate;
153 d->frequency = f; 161 d->frequency = f;
154 d->channels = chs; 162 d->channels = chs;
155 d->bytesPerSample = bps; 163 d->bytesPerSample = bps;
156 // qDebug("%d",bps); 164 // qDebug("%d",bps);
157 int format=0; 165 int format=0;
158 if( bps == 8) format = AFMT_U8; 166 if( bps == 8) format = AFMT_U8;
159 else if( bps <= 0) format = AFMT_S16_LE; 167 else if( bps <= 0) format = AFMT_S16_LE;
160 else format = AFMT_S16_LE; 168 else format = AFMT_S16_LE;
161 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 169 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
162 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 170 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
163 171
164 int fragments = 0x10000 * 8 + sound_fragment_shift; 172 int fragments = 0x10000 * 8 + sound_fragment_shift;
165 int capabilities = 0; 173 int capabilities = 0;
166 174
167 175
168#ifdef KEEP_DEVICE_OPEN 176#ifdef KEEP_DEVICE_OPEN
169 if ( AudioDevicePrivate::dspFd == 0 ) { 177 if ( AudioDevicePrivate::dspFd == 0 ) {
170#endif 178#endif
179#ifdef QT_QWS_DEVFS
180 if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) {
181#else
171 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 182 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
183#endif
172 184
173// perror("open(\"/dev/dsp\") sending to /dev/null instead");
174 perror("open(\"/dev/dsp\")"); 185 perror("open(\"/dev/dsp\")");
175 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); 186 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
176 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); 187 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
177 exit(-1); //harsh? 188 exit(-1); //harsh?
178// d->handle = ::open( "/dev/null", O_WRONLY );
179 // WTF?!?!
180 } 189 }
181#ifdef KEEP_DEVICE_OPEN 190#ifdef KEEP_DEVICE_OPEN
182 AudioDevicePrivate::dspFd = d->handle; 191 AudioDevicePrivate::dspFd = d->handle;
183 } else { 192 } else {
184 d->handle = AudioDevicePrivate::dspFd; 193 d->handle = AudioDevicePrivate::dspFd;
185 } 194 }
186#endif 195#endif
187 196
188 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 197 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
189 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 198 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
190 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 199 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
191 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 200 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
192 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 201 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
193 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 202 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
194 // qDebug("freq %d", d->frequency); 203 // qDebug("freq %d", d->frequency);
195 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 204 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
196 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 205 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
197 // qDebug("channels %d",d->channels); 206 // qDebug("channels %d",d->channels);
198 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 207 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
199 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 208 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
200 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 209 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
201 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 210 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
202 } 211 }
203// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 212// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
204 213
205 d->bufferSize = sound_fragment_bytes; 214 d->bufferSize = sound_fragment_bytes;
206 d->unwrittenBuffer = new char[d->bufferSize]; 215 d->unwrittenBuffer = new char[d->bufferSize];
207 d->unwritten = 0; 216 d->unwritten = 0;
208 d->can_GETOSPACE = TRUE; // until we find otherwise 217 d->can_GETOSPACE = TRUE; // until we find otherwise
209 218
210 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 219 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
211 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 220 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
212 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 221 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
213 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 222 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
214 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 223 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
215 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 224 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
216 225
217} 226}
218 227
219 228
220AudioDevice::~AudioDevice() { 229AudioDevice::~AudioDevice() {
221 // qDebug("destryo audiodevice"); 230 // qDebug("destryo audiodevice");
222// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 231// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
223 232
224# ifndef KEEP_DEVICE_OPEN 233# ifndef KEEP_DEVICE_OPEN
225 close( d->handle ); // Now it should be safe to shut the handle 234 close( d->handle ); // Now it should be safe to shut the handle
226# endif 235# endif
227 delete d->unwrittenBuffer; 236 delete d->unwrittenBuffer;
228 delete d; 237 delete d;
229// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 238// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
230 239
231} 240}
232 241
233 242
234void AudioDevice::volumeChanged( bool muted ) 243void AudioDevice::volumeChanged( bool muted )
235{ 244{
236 AudioDevicePrivate::muted = muted; 245 AudioDevicePrivate::muted = muted;
237} 246}
238 247
239 248
240void AudioDevice::write( char *buffer, unsigned int length ) 249void AudioDevice::write( char *buffer, unsigned int length )
241{ 250{
242 int t = ::write( d->handle, buffer, length ); 251 int t = ::write( d->handle, buffer, length );
243 if ( t<0 ) t = 0; 252 if ( t<0 ) t = 0;
244 if ( t != (int)length) { 253 if ( t != (int)length) {
245 // qDebug("Ahhh!! memcpys 1"); 254 // qDebug("Ahhh!! memcpys 1");
246 memcpy(d->unwrittenBuffer,buffer+t,length-t); 255 memcpy(d->unwrittenBuffer,buffer+t,length-t);
247 d->unwritten = length-t; 256 d->unwritten = length-t;
248 } 257 }
249//#endif 258//#endif
250} 259}
251 260
252 261
253unsigned int AudioDevice::channels() const 262unsigned int AudioDevice::channels() const
254{ 263{
255 return d->channels; 264 return d->channels;
256} 265}
257 266
258 267
259unsigned int AudioDevice::frequency() const 268unsigned int AudioDevice::frequency() const
260{ 269{
261 return d->frequency; 270 return d->frequency;
262} 271}
263 272
264 273
265unsigned int AudioDevice::bytesPerSample() const 274unsigned int AudioDevice::bytesPerSample() const
266{ 275{
267 return d->bytesPerSample; 276 return d->bytesPerSample;
268} 277}
269 278
270 279
271unsigned int AudioDevice::bufferSize() const 280unsigned int AudioDevice::bufferSize() const
272{ 281{
273 return d->bufferSize; 282 return d->bufferSize;
274} 283}
275 284
276unsigned int AudioDevice::canWrite() const 285unsigned int AudioDevice::canWrite() const
277{ 286{
278 audio_buf_info info; 287 audio_buf_info info;
279 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { 288 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
280 d->can_GETOSPACE = FALSE; 289 d->can_GETOSPACE = FALSE;
281 fcntl( d->handle, F_SETFL, O_NONBLOCK ); 290 fcntl( d->handle, F_SETFL, O_NONBLOCK );
282 } 291 }
283 if ( d->can_GETOSPACE ) { 292 if ( d->can_GETOSPACE ) {
284 int t = info.fragments * sound_fragment_bytes; 293 int t = info.fragments * sound_fragment_bytes;
285 return QMIN(t,(int)bufferSize()); 294 return QMIN(t,(int)bufferSize());
286 } else { 295 } else {
287 if ( d->unwritten ) { 296 if ( d->unwritten ) {
288 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); 297 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
289 if ( t<0 ) t = 0; 298 if ( t<0 ) t = 0;
290 if ( (unsigned)t!=d->unwritten ) { 299 if ( (unsigned)t!=d->unwritten ) {
291 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); 300 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
292 d->unwritten -= t; 301 d->unwritten -= t;
293 } else { 302 } else {
294 d->unwritten = 0; 303 d->unwritten = 0;
295 } 304 }
296 } 305 }
297 if ( d->unwritten ) 306 if ( d->unwritten )
298 return 0; 307 return 0;
299 else 308 else
300 return d->bufferSize; 309 return d->bufferSize;
301 } 310 }
302} 311}
303 312
304 313
305int AudioDevice::bytesWritten() { 314int AudioDevice::bytesWritten() {
306 int buffered = 0; 315 int buffered = 0;
307 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 316 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
308 // qDebug( "failed to get audio device position" ); 317 // qDebug( "failed to get audio device position" );
309 return -1; 318 return -1;
310 } 319 }
311 return buffered; 320 return buffered;
312} 321}
313 322
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.cpp b/core/multimedia/opieplayer/libflash/libflashplugin.cpp
index 538c695..78cf555 100644
--- a/core/multimedia/opieplayer/libflash/libflashplugin.cpp
+++ b/core/multimedia/opieplayer/libflash/libflashplugin.cpp
@@ -1,223 +1,227 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "libflashplugin.h" 20#include "libflashplugin.h"
21 21
22#if 0 22#if 0
23 23
24bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { 24bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) {
25} 25}
26 26
27 27
28bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { 28bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) {
29} 29}
30 30
31 31
32bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { 32bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) {
33 samplesRead = samples; 33 samplesRead = samples;
34} 34}
35 35
36 36
37bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { 37bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) {
38} 38}
39 39
40 40
41bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { 41bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) {
42} 42}
43 43
44 44
45bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) { 45bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) {
46/* 46/*
47 int format = MPEG3_RGB565; 47 int format = MPEG3_RGB565;
48 switch ( color_model ) { 48 switch ( color_model ) {
49 case RGB565:format = MPEG3_RGB565; break; 49 case RGB565:format = MPEG3_RGB565; break;
50 case RGBA8888:format = MPEG3_RGBA8888; break; 50 case RGBA8888:format = MPEG3_RGBA8888; break;
51 case BGRA8888:format = MPEG3_BGRA8888; break; 51 case BGRA8888:format = MPEG3_BGRA8888; break;
52 } 52 }
53*/ 53*/
54} 54}
55 55
56 56
57bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) { 57bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) {
58} 58}
59 59
60 60
61FlashHandle file; 61FlashHandle file;
62FlashDisplay *fd; 62FlashDisplay *fd;
63 63
64#endif 64#endif
65 65
66 66
67LibFlashPlugin::LibFlashPlugin() { 67LibFlashPlugin::LibFlashPlugin() {
68 file = NULL; 68 file = NULL;
69 fd = 0; 69 fd = 0;
70} 70}
71#include <stdio.h> 71#include <stdio.h>
72#include <stdlib.h> 72#include <stdlib.h>
73static int readFile(const char *filename, char **buffer, long *size) 73static int readFile(const char *filename, char **buffer, long *size)
74{ 74{
75 FILE *in; 75 FILE *in;
76 char *buf; 76 char *buf;
77 long length; 77 long length;
78 78
79 printf("read files\n"); 79 printf("read files\n");
80 80
81 in = fopen(filename,"r"); 81 in = fopen(filename,"r");
82 if (in == 0) { 82 if (in == 0) {
83 perror(filename); 83 perror(filename);
84 return -1; 84 return -1;
85 } 85 }
86 fseek(in,0,SEEK_END); 86 fseek(in,0,SEEK_END);
87 length = ftell(in); 87 length = ftell(in);
88 rewind(in); 88 rewind(in);
89 buf = (char *)malloc(length); 89 buf = (char *)malloc(length);
90 fread(buf,length,1,in); 90 fread(buf,length,1,in);
91 fclose(in); 91 fclose(in);
92 92
93 *size = length; 93 *size = length;
94 *buffer = buf; 94 *buffer = buf;
95 95
96 return length; 96 return length;
97} 97}
98 98
99static void showUrl(char *url, char * /*target*/, void * /*client_data*/) { 99static void showUrl(char *url, char * /*target*/, void * /*client_data*/) {
100 printf("get url\n"); 100 printf("get url\n");
101 printf("GetURL : %s\n", url); 101 printf("GetURL : %s\n", url);
102} 102}
103 103
104static void getSwf(char *url, int level, void *client_data) { 104static void getSwf(char *url, int level, void *client_data) {
105 FlashHandle flashHandle = (FlashHandle) client_data; 105 FlashHandle flashHandle = (FlashHandle) client_data;
106 char *buffer; 106 char *buffer;
107 long size; 107 long size;
108 108
109 printf("get swf\n"); 109 printf("get swf\n");
110 110
111 printf("LoadMovie: %s @ %d\n", url, level); 111 printf("LoadMovie: %s @ %d\n", url, level);
112 if (readFile(url, &buffer, &size) > 0) { 112 if (readFile(url, &buffer, &size) > 0) {
113 FlashParse(flashHandle, level, buffer, size); 113 FlashParse(flashHandle, level, buffer, size);
114 } 114 }
115} 115}
116 116
117bool LibFlashPlugin::open( const QString& fileName ) { 117bool LibFlashPlugin::open( const QString& fileName ) {
118 118
119 printf("opening file\n"); 119 printf("opening file\n");
120 120
121 delete fd; 121 delete fd;
122 fd = new FlashDisplay; 122 fd = new FlashDisplay;
123 fd->pixels = new int[320*240*4]; 123 fd->pixels = new int[320*240*4];
124 fd->width = 200; 124 fd->width = 200;
125 fd->bpl = 320*2; 125 fd->bpl = 320*2;
126 fd->height = 300; 126 fd->height = 300;
127 fd->depth = 16; 127 fd->depth = 16;
128 fd->bpp = 2; 128 fd->bpp = 2;
129 fd->flash_refresh = 25; 129 fd->flash_refresh = 25;
130 fd->clip_x = 0; 130 fd->clip_x = 0;
131 fd->clip_y = 0; 131 fd->clip_y = 0;
132 fd->clip_width = 0; 132 fd->clip_width = 0;
133 fd->clip_height = 0; 133 fd->clip_height = 0;
134 134
135 char *buffer; 135 char *buffer;
136 long size; 136 long size;
137 int status; 137 int status;
138 struct FlashInfo fi; 138 struct FlashInfo fi;
139 139
140 if (readFile(fileName.latin1(), &buffer, &size) < 0) 140 if (readFile(fileName.latin1(), &buffer, &size) < 0)
141 exit(2); 141 exit(2);
142 142
143 if (!(file = FlashNew())) 143 if (!(file = FlashNew()))
144 exit(1); 144 exit(1);
145 145
146 do 146 do
147 status = FlashParse(file, 0, buffer, size); 147 status = FlashParse(file, 0, buffer, size);
148 while (status & FLASH_PARSE_NEED_DATA); 148 while (status & FLASH_PARSE_NEED_DATA);
149 149
150 free(buffer); 150 free(buffer);
151 FlashGetInfo(file, &fi); 151 FlashGetInfo(file, &fi);
152 //FlashSettings(flashHandle, PLAYER_LOOP); 152 //FlashSettings(flashHandle, PLAYER_LOOP);
153 FlashGraphicInit(file, fd); 153 FlashGraphicInit(file, fd);
154#ifdef QT_QWS_DEVFS
155 FlashSoundInit(file, "/dev/sound/dsp");
156#else
154 FlashSoundInit(file, "/dev/dsp"); 157 FlashSoundInit(file, "/dev/dsp");
158#endif
155 FlashSetGetUrlMethod(file, showUrl, 0); 159 FlashSetGetUrlMethod(file, showUrl, 0);
156 FlashSetGetSwfMethod(file, getSwf, (void*)file); 160 FlashSetGetSwfMethod(file, getSwf, (void*)file);
157 161
158 printf("opened file\n"); 162 printf("opened file\n");
159} 163}
160 164
161// If decoder doesn't support audio then return 0 here 165// If decoder doesn't support audio then return 0 here
162bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; } 166bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; }
163long LibFlashPlugin::audioGetSample( int stream ) { return 0; } 167long LibFlashPlugin::audioGetSample( int stream ) { return 0; }
164//bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; } 168//bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; }
165//bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; } 169//bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; }
166bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; } 170bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; }
167//bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } 171//bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
168//bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } 172//bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; }
169 173
170// If decoder doesn't support video then return 0 here 174// If decoder doesn't support video then return 0 here
171int LibFlashPlugin::videoStreams() { return 1; } 175int LibFlashPlugin::videoStreams() { return 1; }
172int LibFlashPlugin::videoWidth( int stream ) { return 300; } 176int LibFlashPlugin::videoWidth( int stream ) { return 300; }
173int LibFlashPlugin::videoHeight( int stream ) { return 200; } 177int LibFlashPlugin::videoHeight( int stream ) { return 200; }
174double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; } 178double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; }
175int LibFlashPlugin::videoFrames( int stream ) { return 1000000; } 179int LibFlashPlugin::videoFrames( int stream ) { return 1000000; }
176bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; } 180bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; }
177long LibFlashPlugin::videoGetFrame( int stream ) { return 0; } 181long LibFlashPlugin::videoGetFrame( int stream ) { return 0; }
178bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { return TRUE; } 182bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { return TRUE; }
179#include <time.h> 183#include <time.h>
180bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) { 184bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) {
181 struct timeval wd; 185 struct timeval wd;
182 FlashEvent fe; 186 FlashEvent fe;
183 187
184/* 188/*
185 delete fd; 189 delete fd;
186 fd = new FlashDisplay; 190 fd = new FlashDisplay;
187 fd->pixels = output_rows[0]; 191 fd->pixels = output_rows[0];
188 fd->width = 300; // out_w; 192 fd->width = 300; // out_w;
189 fd->bpl = 640; // out_w*2; 193 fd->bpl = 640; // out_w*2;
190 fd->height = 200;//out_h; 194 fd->height = 200;//out_h;
191 fd->depth = 16; 195 fd->depth = 16;
192 fd->bpp = 2; 196 fd->bpp = 2;
193 fd->flash_refresh = 50; 197 fd->flash_refresh = 50;
194 fd->clip_x = 0;//in_x; 198 fd->clip_x = 0;//in_x;
195 fd->clip_y = 0;//in_y; 199 fd->clip_y = 0;//in_y;
196 fd->clip_width = 300;//in_w; 200 fd->clip_width = 300;//in_w;
197 fd->clip_height = 200;//in_h; 201 fd->clip_height = 200;//in_h;
198 FlashGraphicInit(file, fd); 202 FlashGraphicInit(file, fd);
199*/ 203*/
200 204
201 long cmd = FLASH_WAKEUP; 205 long cmd = FLASH_WAKEUP;
202 FlashExec(file, cmd, 0, &wd); 206 FlashExec(file, cmd, 0, &wd);
203 207
204 fe.type = FeRefresh; 208 fe.type = FeRefresh;
205 cmd = FLASH_EVENT; 209 cmd = FLASH_EVENT;
206 FlashExec(file, cmd, &fe, &wd); 210 FlashExec(file, cmd, &fe, &wd);
207/* 211/*
208 for (int i = 0; i < out_h; i++) 212 for (int i = 0; i < out_h; i++)
209 memcpy( output_rows[i], (char*)fd->pixels + i*fd->bpl, QMIN( fd->width * fd->bpp, out_w * fd->bpp ) ); 213 memcpy( output_rows[i], (char*)fd->pixels + i*fd->bpl, QMIN( fd->width * fd->bpp, out_w * fd->bpp ) );
210 */ 214 */
211 memcpy( output_rows[0], (char*)fd->pixels, out_w * out_h * 2 ); 215 memcpy( output_rows[0], (char*)fd->pixels, out_w * out_h * 2 );
212} 216}
213 217
214bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) { return TRUE; } 218bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) { return TRUE; }
215 219
216// Profiling 220// Profiling
217double LibFlashPlugin::getTime() { return 0.0; } 221double LibFlashPlugin::getTime() { return 0.0; }
218 222
219// Ignore if these aren't supported 223// Ignore if these aren't supported
220bool LibFlashPlugin::setSMP( int cpus ) { return TRUE; } 224bool LibFlashPlugin::setSMP( int cpus ) { return TRUE; }
221bool LibFlashPlugin::setMMX( bool useMMX ) { return TRUE; } 225bool LibFlashPlugin::setMMX( bool useMMX ) { return TRUE; }
222 226
223 227
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index efea385..b393230 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -607,872 +607,876 @@ const DocLnk *PlayListWidget::current() { // this is fugly
607 return Vdit; 607 return Vdit;
608 } 608 }
609 } 609 }
610 } 610 }
611 break; 611 break;
612 }; 612 };
613 return 0; 613 return 0;
614} 614}
615 615
616bool PlayListWidget::prev() { 616bool PlayListWidget::prev() {
617 if ( mediaPlayerState->playlist() ) { 617 if ( mediaPlayerState->playlist() ) {
618 if ( mediaPlayerState->shuffled() ) { 618 if ( mediaPlayerState->shuffled() ) {
619 const DocLnk *cur = current(); 619 const DocLnk *cur = current();
620 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 620 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
621 for ( int i = 0; i < j; i++ ) { 621 for ( int i = 0; i < j; i++ ) {
622 if ( !d->selectedFiles->next() ) 622 if ( !d->selectedFiles->next() )
623 d->selectedFiles->first(); 623 d->selectedFiles->first();
624 } 624 }
625 if ( cur == current() ) 625 if ( cur == current() )
626 if ( !d->selectedFiles->next() ) 626 if ( !d->selectedFiles->next() )
627 d->selectedFiles->first(); 627 d->selectedFiles->first();
628 return TRUE; 628 return TRUE;
629 } else { 629 } else {
630 if ( !d->selectedFiles->prev() ) { 630 if ( !d->selectedFiles->prev() ) {
631 if ( mediaPlayerState->looping() ) { 631 if ( mediaPlayerState->looping() ) {
632 return d->selectedFiles->last(); 632 return d->selectedFiles->last();
633 } else { 633 } else {
634 return FALSE; 634 return FALSE;
635 } 635 }
636 } 636 }
637 return TRUE; 637 return TRUE;
638 } 638 }
639 } else { 639 } else {
640 return mediaPlayerState->looping(); 640 return mediaPlayerState->looping();
641 } 641 }
642} 642}
643 643
644 644
645bool PlayListWidget::next() { 645bool PlayListWidget::next() {
646 if ( mediaPlayerState->playlist() ) { 646 if ( mediaPlayerState->playlist() ) {
647 if ( mediaPlayerState->shuffled() ) { 647 if ( mediaPlayerState->shuffled() ) {
648 return prev(); 648 return prev();
649 } else { 649 } else {
650 if ( !d->selectedFiles->next() ) { 650 if ( !d->selectedFiles->next() ) {
651 if ( mediaPlayerState->looping() ) { 651 if ( mediaPlayerState->looping() ) {
652 return d->selectedFiles->first(); 652 return d->selectedFiles->first();
653 } else { 653 } else {
654 return FALSE; 654 return FALSE;
655 } 655 }
656 } 656 }
657 return TRUE; 657 return TRUE;
658 } 658 }
659 } else { 659 } else {
660 return mediaPlayerState->looping(); 660 return mediaPlayerState->looping();
661 } 661 }
662} 662}
663 663
664 664
665bool PlayListWidget::first() { 665bool PlayListWidget::first() {
666 if ( mediaPlayerState->playlist() ) 666 if ( mediaPlayerState->playlist() )
667 return d->selectedFiles->first(); 667 return d->selectedFiles->first();
668 else 668 else
669 return mediaPlayerState->looping(); 669 return mediaPlayerState->looping();
670} 670}
671 671
672 672
673bool PlayListWidget::last() { 673bool PlayListWidget::last() {
674 if ( mediaPlayerState->playlist() ) 674 if ( mediaPlayerState->playlist() )
675 return d->selectedFiles->last(); 675 return d->selectedFiles->last();
676 else 676 else
677 return mediaPlayerState->looping(); 677 return mediaPlayerState->looping();
678} 678}
679 679
680 680
681void PlayListWidget::saveList() { 681void PlayListWidget::saveList() {
682 writem3u(); 682 writem3u();
683} 683}
684 684
685void PlayListWidget::loadList( const DocLnk & lnk) { 685void PlayListWidget::loadList( const DocLnk & lnk) {
686 QString name = lnk.name(); 686 QString name = lnk.name();
687 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 687 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
688 688
689 if( name.length()>0) { 689 if( name.length()>0) {
690 setCaption("OpiePlayer: "+name); 690 setCaption("OpiePlayer: "+name);
691 // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 691 // qDebug("<<<<<<<<<<<<load list "+ lnk.file());
692 clearList(); 692 clearList();
693 readm3u(lnk.file()); 693 readm3u(lnk.file());
694 tabWidget->setCurrentPage(0); 694 tabWidget->setCurrentPage(0);
695 } 695 }
696} 696}
697 697
698void PlayListWidget::setPlaylist( bool shown ) { 698void PlayListWidget::setPlaylist( bool shown ) {
699 if ( shown ) 699 if ( shown )
700 d->playListFrame->show(); 700 d->playListFrame->show();
701 else 701 else
702 d->playListFrame->hide(); 702 d->playListFrame->hide();
703} 703}
704 704
705void PlayListWidget::setView( char view ) { 705void PlayListWidget::setView( char view ) {
706 if ( view == 'l' ) 706 if ( view == 'l' )
707 showMaximized(); 707 showMaximized();
708 else 708 else
709 hide(); 709 hide();
710} 710}
711 711
712void PlayListWidget::addSelected() { 712void PlayListWidget::addSelected() {
713 DocLnk lnk; 713 DocLnk lnk;
714 QString filename; 714 QString filename;
715 switch (tabWidget->currentPageIndex()) { 715 switch (tabWidget->currentPageIndex()) {
716 716
717 case 0: //playlist 717 case 0: //playlist
718 return; 718 return;
719 break; 719 break;
720 case 1: { //audio 720 case 1: { //audio
721 QListViewItemIterator it( audioView ); 721 QListViewItemIterator it( audioView );
722 for ( ; it.current(); ++it ) { 722 for ( ; it.current(); ++it ) {
723 if ( it.current()->isSelected() ) { 723 if ( it.current()->isSelected() ) {
724 filename = it.current()->text(3); 724 filename = it.current()->text(3);
725 lnk.setName( QFileInfo(filename).baseName() ); //sets name 725 lnk.setName( QFileInfo(filename).baseName() ); //sets name
726 lnk.setFile( filename ); //sets file name 726 lnk.setFile( filename ); //sets file name
727 d->selectedFiles->addToSelection( lnk); 727 d->selectedFiles->addToSelection( lnk);
728 } 728 }
729 } 729 }
730 audioView->clearSelection(); 730 audioView->clearSelection();
731 // d->selectedFiles->next(); 731 // d->selectedFiles->next();
732 } 732 }
733 break; 733 break;
734 734
735 case 2: { // video 735 case 2: { // video
736 QListViewItemIterator it( videoView ); 736 QListViewItemIterator it( videoView );
737 for ( ; it.current(); ++it ) { 737 for ( ; it.current(); ++it ) {
738 if ( it.current()->isSelected() ) { 738 if ( it.current()->isSelected() ) {
739 739
740 filename = it.current()->text(3); 740 filename = it.current()->text(3);
741 lnk.setName( QFileInfo(filename).baseName() ); //sets name 741 lnk.setName( QFileInfo(filename).baseName() ); //sets name
742 lnk.setFile( filename ); //sets file name 742 lnk.setFile( filename ); //sets file name
743 d->selectedFiles->addToSelection( lnk); 743 d->selectedFiles->addToSelection( lnk);
744 } 744 }
745 } 745 }
746 videoView->clearSelection(); 746 videoView->clearSelection();
747 } 747 }
748 break; 748 break;
749 }; 749 };
750 // tabWidget->setCurrentPage(0); 750 // tabWidget->setCurrentPage(0);
751 writeCurrentM3u(); 751 writeCurrentM3u();
752 752
753} 753}
754 754
755void PlayListWidget::removeSelected() { 755void PlayListWidget::removeSelected() {
756 d->selectedFiles->removeSelected( ); 756 d->selectedFiles->removeSelected( );
757} 757}
758 758
759void PlayListWidget::playIt( QListViewItem *) { 759void PlayListWidget::playIt( QListViewItem *) {
760 // d->setDocumentUsed = FALSE; 760 // d->setDocumentUsed = FALSE;
761 // mediaPlayerState->curPosition =0; 761 // mediaPlayerState->curPosition =0;
762 // mediaPlayerState->setPlaying(FALSE); 762 // mediaPlayerState->setPlaying(FALSE);
763 mediaPlayerState->setPlaying(TRUE); 763 mediaPlayerState->setPlaying(TRUE);
764 d->selectedFiles->unSelect(); 764 d->selectedFiles->unSelect();
765} 765}
766 766
767void PlayListWidget::addToSelection( QListViewItem *it) { 767void PlayListWidget::addToSelection( QListViewItem *it) {
768 d->setDocumentUsed = FALSE; 768 d->setDocumentUsed = FALSE;
769 769
770 if(it) { 770 if(it) {
771 switch ( tabWidget->currentPageIndex()) { 771 switch ( tabWidget->currentPageIndex()) {
772 case 0: //playlist 772 case 0: //playlist
773 return; 773 return;
774 break; 774 break;
775 }; 775 };
776 // case 1: { 776 // case 1: {
777 DocLnk lnk; 777 DocLnk lnk;
778 QString filename; 778 QString filename;
779 779
780 filename=it->text(3); 780 filename=it->text(3);
781 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 781 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
782 lnk.setFile( filename ); //sets file name 782 lnk.setFile( filename ); //sets file name
783 d->selectedFiles->addToSelection( lnk); 783 d->selectedFiles->addToSelection( lnk);
784 784
785 if(tabWidget->currentPageIndex() == 0) 785 if(tabWidget->currentPageIndex() == 0)
786 writeCurrentM3u(); 786 writeCurrentM3u();
787 // tabWidget->setCurrentPage(0); 787 // tabWidget->setCurrentPage(0);
788 788
789 } 789 }
790} 790}
791 791
792void PlayListWidget::tabChanged(QWidget *) { 792void PlayListWidget::tabChanged(QWidget *) {
793 793
794 switch ( tabWidget->currentPageIndex()) { 794 switch ( tabWidget->currentPageIndex()) {
795 case 0: 795 case 0:
796 { 796 {
797 if( !tbDeletePlaylist->isHidden()) 797 if( !tbDeletePlaylist->isHidden())
798 tbDeletePlaylist->hide(); 798 tbDeletePlaylist->hide();
799 d->tbRemoveFromList->setEnabled(TRUE); 799 d->tbRemoveFromList->setEnabled(TRUE);
800 d->tbAddToList->setEnabled(FALSE); 800 d->tbAddToList->setEnabled(FALSE);
801 } 801 }
802 break; 802 break;
803 case 1: 803 case 1:
804 { 804 {
805 audioView->clear(); 805 audioView->clear();
806 populateAudioView(); 806 populateAudioView();
807 807
808 if( !tbDeletePlaylist->isHidden()) 808 if( !tbDeletePlaylist->isHidden())
809 tbDeletePlaylist->hide(); 809 tbDeletePlaylist->hide();
810 d->tbRemoveFromList->setEnabled(FALSE); 810 d->tbRemoveFromList->setEnabled(FALSE);
811 d->tbAddToList->setEnabled(TRUE); 811 d->tbAddToList->setEnabled(TRUE);
812 } 812 }
813 break; 813 break;
814 case 2: 814 case 2:
815 { 815 {
816 videoView->clear(); 816 videoView->clear();
817 populateVideoView(); 817 populateVideoView();
818 if( !tbDeletePlaylist->isHidden()) 818 if( !tbDeletePlaylist->isHidden())
819 tbDeletePlaylist->hide(); 819 tbDeletePlaylist->hide();
820 d->tbRemoveFromList->setEnabled(FALSE); 820 d->tbRemoveFromList->setEnabled(FALSE);
821 d->tbAddToList->setEnabled(TRUE); 821 d->tbAddToList->setEnabled(TRUE);
822 } 822 }
823 break; 823 break;
824 case 3: 824 case 3:
825 { 825 {
826 if( tbDeletePlaylist->isHidden()) 826 if( tbDeletePlaylist->isHidden())
827 tbDeletePlaylist->show(); 827 tbDeletePlaylist->show();
828 playLists->reread(); 828 playLists->reread();
829 } 829 }
830 break; 830 break;
831 }; 831 };
832} 832}
833 833
834void PlayListWidget::btnPlay(bool b) { 834void PlayListWidget::btnPlay(bool b) {
835 // mediaPlayerState->setPlaying(b); 835 // mediaPlayerState->setPlaying(b);
836 switch ( tabWidget->currentPageIndex()) { 836 switch ( tabWidget->currentPageIndex()) {
837 case 0: 837 case 0:
838 { 838 {
839 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 839 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
840 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 840 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
841 // QMessageBox::message("Note","You are trying to play\na malformed url."); 841 // QMessageBox::message("Note","You are trying to play\na malformed url.");
842 // } else { 842 // } else {
843 mediaPlayerState->setPlaying(b); 843 mediaPlayerState->setPlaying(b);
844 insanityBool=FALSE; 844 insanityBool=FALSE;
845 qDebug("insanity"); 845 qDebug("insanity");
846 // } 846 // }
847 } 847 }
848 break; 848 break;
849 case 1: 849 case 1:
850 { 850 {
851 // d->selectedFiles->unSelect(); 851 // d->selectedFiles->unSelect();
852 addToSelection( audioView->currentItem() ); 852 addToSelection( audioView->currentItem() );
853 mediaPlayerState->setPlaying( b); 853 mediaPlayerState->setPlaying( b);
854 d->selectedFiles->removeSelected( ); 854 d->selectedFiles->removeSelected( );
855 d->selectedFiles->unSelect(); 855 d->selectedFiles->unSelect();
856 tabWidget->setCurrentPage(1); 856 tabWidget->setCurrentPage(1);
857 insanityBool=FALSE; 857 insanityBool=FALSE;
858 }// audioView->clearSelection(); 858 }// audioView->clearSelection();
859 break; 859 break;
860 case 2: 860 case 2:
861 { 861 {
862 862
863 addToSelection( videoView->currentItem() ); 863 addToSelection( videoView->currentItem() );
864 mediaPlayerState->setPlaying( b); 864 mediaPlayerState->setPlaying( b);
865 // qApp->processEvents(); 865 // qApp->processEvents();
866 d->selectedFiles->removeSelected( ); 866 d->selectedFiles->removeSelected( );
867 d->selectedFiles->unSelect(); 867 d->selectedFiles->unSelect();
868 tabWidget->setCurrentPage(2); 868 tabWidget->setCurrentPage(2);
869 insanityBool=FALSE; 869 insanityBool=FALSE;
870 }// videoView->clearSelection(); 870 }// videoView->clearSelection();
871 break; 871 break;
872 }; 872 };
873 873
874} 874}
875 875
876void PlayListWidget::deletePlaylist() { 876void PlayListWidget::deletePlaylist() {
877 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 877 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
878 (tr("You really want to delete\nthis playlist?")), 878 (tr("You really want to delete\nthis playlist?")),
879 (tr("Yes")), (tr("No")), 0 )){ 879 (tr("Yes")), (tr("No")), 0 )){
880 case 0: // Yes clicked, 880 case 0: // Yes clicked,
881 QFile().remove(playLists->selectedDocument().file()); 881 QFile().remove(playLists->selectedDocument().file());
882 QFile().remove(playLists->selectedDocument().linkFile()); 882 QFile().remove(playLists->selectedDocument().linkFile());
883 playLists->reread(); 883 playLists->reread();
884 break; 884 break;
885 case 1: // Cancel 885 case 1: // Cancel
886 break; 886 break;
887 }; 887 };
888} 888}
889 889
890void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 890void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
891{ 891{
892 switch (mouse) { 892 switch (mouse) {
893 case 1: 893 case 1:
894 break; 894 break;
895 case 2:{ 895 case 2:{
896 896
897 QPopupMenu m; 897 QPopupMenu m;
898 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 898 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
899 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 899 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
900 m.insertSeparator(); 900 m.insertSeparator();
901 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 901 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
902 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 902 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
903 903
904 m.exec( QCursor::pos() ); 904 m.exec( QCursor::pos() );
905 } 905 }
906 break; 906 break;
907 }; 907 };
908} 908}
909 909
910void PlayListWidget::playSelected() 910void PlayListWidget::playSelected()
911{ 911{
912 btnPlay( true); 912 btnPlay( true);
913// d->selectedFiles->unSelect(); 913// d->selectedFiles->unSelect();
914} 914}
915 915
916void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 916void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
917{ 917{
918 switch (mouse) { 918 switch (mouse) {
919 case 1: 919 case 1:
920 920
921 break; 921 break;
922 case 2:{ 922 case 2:{
923 QPopupMenu m; 923 QPopupMenu m;
924 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 924 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
925 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 925 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
926 // m.insertSeparator(); 926 // m.insertSeparator();
927 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 927 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
928 m.exec( QCursor::pos() ); 928 m.exec( QCursor::pos() );
929 } 929 }
930 break; 930 break;
931 }; 931 };
932 932
933} 933}
934 934
935void PlayListWidget::listDelete() { 935void PlayListWidget::listDelete() {
936 Config cfg( "OpiePlayer" ); 936 Config cfg( "OpiePlayer" );
937 cfg.setGroup("PlayList"); 937 cfg.setGroup("PlayList");
938 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 938 currentPlayList = cfg.readEntry("CurrentPlaylist","");
939 QString file; 939 QString file;
940 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 940 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
941 switch ( tabWidget->currentPageIndex()) { 941 switch ( tabWidget->currentPageIndex()) {
942 case 0: 942 case 0:
943 break; 943 break;
944 case 1: 944 case 1:
945 { 945 {
946 file = audioView->currentItem()->text(0); 946 file = audioView->currentItem()->text(0);
947 QListIterator<DocLnk> Pdit( files.children() ); 947 QListIterator<DocLnk> Pdit( files.children() );
948 for ( ; Pdit.current(); ++Pdit ) { 948 for ( ; Pdit.current(); ++Pdit ) {
949 if( Pdit.current()->name() == file) { 949 if( Pdit.current()->name() == file) {
950 LnkProperties prop( Pdit.current() ); 950 LnkProperties prop( Pdit.current() );
951 prop.showMaximized(); 951 prop.showMaximized();
952 prop.exec(); 952 prop.exec();
953 } 953 }
954 } 954 }
955 populateAudioView(); 955 populateAudioView();
956 } 956 }
957 break; 957 break;
958 case 2: 958 case 2:
959 { 959 {
960 // file = videoView->selectedItem()->text(0); 960 // file = videoView->selectedItem()->text(0);
961 // for ( int i = 0; i < noOfFiles; i++ ) { 961 // for ( int i = 0; i < noOfFiles; i++ ) {
962 // QString entryName; 962 // QString entryName;
963 // entryName.sprintf( "File%i", i + 1 ); 963 // entryName.sprintf( "File%i", i + 1 );
964 // QString linkFile = cfg.readEntry( entryName ); 964 // QString linkFile = cfg.readEntry( entryName );
965 // AppLnk lnk( AppLnk(linkFile)); 965 // AppLnk lnk( AppLnk(linkFile));
966 // if( lnk.name() == file ) { 966 // if( lnk.name() == file ) {
967 // LnkProperties prop( &lnk); 967 // LnkProperties prop( &lnk);
968 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 968 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
969 // prop.showMaximized(); 969 // prop.showMaximized();
970 // prop.exec(); 970 // prop.exec();
971 // } 971 // }
972 // } 972 // }
973 } 973 }
974 break; 974 break;
975 }; 975 };
976} 976}
977 977
978void PlayListWidget::scanForAudio() { 978void PlayListWidget::scanForAudio() {
979 // qDebug("scan for audio"); 979 // qDebug("scan for audio");
980 files.detachChildren(); 980 files.detachChildren();
981 QListIterator<DocLnk> sdit( files.children() ); 981 QListIterator<DocLnk> sdit( files.children() );
982 for ( ; sdit.current(); ++sdit ) { 982 for ( ; sdit.current(); ++sdit ) {
983 delete sdit.current(); 983 delete sdit.current();
984 } 984 }
985 Global::findDocuments( &files, audioMimes); 985 Global::findDocuments( &files, audioMimes);
986 audioScan = true; 986 audioScan = true;
987} 987}
988void PlayListWidget::scanForVideo() { 988void PlayListWidget::scanForVideo() {
989 // qDebug("scan for video"); 989 // qDebug("scan for video");
990 vFiles.detachChildren(); 990 vFiles.detachChildren();
991 QListIterator<DocLnk> sdit( vFiles.children() ); 991 QListIterator<DocLnk> sdit( vFiles.children() );
992 for ( ; sdit.current(); ++sdit ) { 992 for ( ; sdit.current(); ++sdit ) {
993 delete sdit.current(); 993 delete sdit.current();
994 } 994 }
995 Global::findDocuments(&vFiles, "video/*"); 995 Global::findDocuments(&vFiles, "video/*");
996 videoScan = true; 996 videoScan = true;
997} 997}
998 998
999void PlayListWidget::populateAudioView() { 999void PlayListWidget::populateAudioView() {
1000 1000
1001 audioView->clear(); 1001 audioView->clear();
1002 StorageInfo storageInfo; 1002 StorageInfo storageInfo;
1003 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1003 const QList<FileSystem> &fs = storageInfo.fileSystems();
1004 if(!audioScan) scanForAudio(); 1004 if(!audioScan) scanForAudio();
1005 1005
1006 QListIterator<DocLnk> dit( files.children() ); 1006 QListIterator<DocLnk> dit( files.children() );
1007 QListIterator<FileSystem> it ( fs ); 1007 QListIterator<FileSystem> it ( fs );
1008 1008
1009 QString storage; 1009 QString storage;
1010 for ( ; dit.current(); ++dit ) { 1010 for ( ; dit.current(); ++dit ) {
1011 for( ; it.current(); ++it ){ 1011 for( ; it.current(); ++it ){
1012 const QString name = (*it)->name(); 1012 const QString name = (*it)->name();
1013 const QString path = (*it)->path(); 1013 const QString path = (*it)->path();
1014 if(dit.current()->file().find(path) != -1 ) storage=name; 1014 if(dit.current()->file().find(path) != -1 ) storage=name;
1015 } 1015 }
1016 1016
1017 QListViewItem * newItem; 1017 QListViewItem * newItem;
1018 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1018 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1019 long size; 1019 long size;
1020 if( dit.current()->file().left(4) == "http" ) 1020 if( dit.current()->file().left(4) == "http" )
1021 size=0; 1021 size=0;
1022 else 1022 else
1023 size = QFile( dit.current()->file() ).size(); 1023 size = QFile( dit.current()->file() ).size();
1024 // qDebug(dit.current()->name()); 1024 // qDebug(dit.current()->name());
1025 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1025 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1026 QString::number(size ), storage, dit.current()->file()); 1026 QString::number(size ), storage, dit.current()->file());
1027 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1027 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1028 } 1028 }
1029 } 1029 }
1030 1030
1031} 1031}
1032 1032
1033void PlayListWidget::populateVideoView() { 1033void PlayListWidget::populateVideoView() {
1034 videoView->clear(); 1034 videoView->clear();
1035 StorageInfo storageInfo; 1035 StorageInfo storageInfo;
1036 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1036 const QList<FileSystem> &fs = storageInfo.fileSystems();
1037 1037
1038 if(!videoScan ) scanForVideo(); 1038 if(!videoScan ) scanForVideo();
1039 1039
1040 QListIterator<DocLnk> Vdit( vFiles.children() ); 1040 QListIterator<DocLnk> Vdit( vFiles.children() );
1041 QListIterator<FileSystem> it ( fs ); 1041 QListIterator<FileSystem> it ( fs );
1042 videoView->clear(); 1042 videoView->clear();
1043 QString storage; 1043 QString storage;
1044 for ( ; Vdit.current(); ++Vdit ) { 1044 for ( ; Vdit.current(); ++Vdit ) {
1045 for( ; it.current(); ++it ){ 1045 for( ; it.current(); ++it ){
1046 const QString name = (*it)->name(); 1046 const QString name = (*it)->name();
1047 const QString path = (*it)->path(); 1047 const QString path = (*it)->path();
1048 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1048 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1049 } 1049 }
1050 1050
1051 QListViewItem * newItem; 1051 QListViewItem * newItem;
1052 if ( QFile( Vdit.current()->file()).exists() ) { 1052 if ( QFile( Vdit.current()->file()).exists() ) {
1053 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1053 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1054 QString::number( QFile( Vdit.current()->file() ).size() ), 1054 QString::number( QFile( Vdit.current()->file() ).size() ),
1055 storage, Vdit.current()->file()); 1055 storage, Vdit.current()->file());
1056 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1056 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1057 } 1057 }
1058 } 1058 }
1059} 1059}
1060 1060
1061void PlayListWidget::openFile() { 1061void PlayListWidget::openFile() {
1062 QString filename, name; 1062 QString filename, name;
1063 InputDialog *fileDlg; 1063 InputDialog *fileDlg;
1064 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1064 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1065 fileDlg->exec(); 1065 fileDlg->exec();
1066 if( fileDlg->result() == 1 ) { 1066 if( fileDlg->result() == 1 ) {
1067 filename = fileDlg->text(); 1067 filename = fileDlg->text();
1068 // qDebug( "Selected filename is " + filename ); 1068 // qDebug( "Selected filename is " + filename );
1069 DocLnk lnk; 1069 DocLnk lnk;
1070 Config cfg( "OpiePlayer" ); 1070 Config cfg( "OpiePlayer" );
1071 cfg.setGroup("PlayList"); 1071 cfg.setGroup("PlayList");
1072 1072
1073 QString m3uFile; 1073 QString m3uFile;
1074 m3uFile = filename; 1074 m3uFile = filename;
1075 if(filename.left(4) == "http") { 1075 if(filename.left(4) == "http") {
1076 if(filename.find(":",8,TRUE) != -1) { //found a port 1076 if(filename.find(":",8,TRUE) != -1) { //found a port
1077 1077
1078 m3uFile = filename; 1078 m3uFile = filename;
1079 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1079 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1080 m3uFile += "/"; 1080 m3uFile += "/";
1081 } 1081 }
1082 filename = m3uFile; 1082 filename = m3uFile;
1083 } 1083 }
1084 lnk.setName( m3uFile ); //sets name 1084 lnk.setName( m3uFile ); //sets name
1085 lnk.setFile( filename ); //sets file name 1085 lnk.setFile( filename ); //sets file name
1086 lnk.setIcon("opieplayer2/musicfile"); 1086 lnk.setIcon("opieplayer2/musicfile");
1087 d->selectedFiles->addToSelection( lnk ); 1087 d->selectedFiles->addToSelection( lnk );
1088 writeCurrentM3u(); 1088 writeCurrentM3u();
1089 } 1089 }
1090 else if( filename.right( 3) == "m3u" ) { 1090 else if( filename.right( 3) == "m3u" ) {
1091 readm3u( filename ); 1091 readm3u( filename );
1092 1092
1093 } else if( filename.right(3) == "pls" ) { 1093 } else if( filename.right(3) == "pls" ) {
1094 readPls( filename ); 1094 readPls( filename );
1095 } else { 1095 } else {
1096 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1096 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1097 lnk.setFile( filename ); //sets file name 1097 lnk.setFile( filename ); //sets file name
1098 d->selectedFiles->addToSelection( lnk); 1098 d->selectedFiles->addToSelection( lnk);
1099 lnk.removeLinkFile(); 1099 lnk.removeLinkFile();
1100 writeCurrentM3u(); 1100 writeCurrentM3u();
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 if( fileDlg ) { 1104 if( fileDlg ) {
1105 delete fileDlg; 1105 delete fileDlg;
1106 } 1106 }
1107} 1107}
1108 1108
1109 1109
1110/* 1110/*
1111reads m3u and shows files/urls to playlist widget */ 1111reads m3u and shows files/urls to playlist widget */
1112void PlayListWidget::readm3u( const QString &filename ) { 1112void PlayListWidget::readm3u( const QString &filename ) {
1113 // qDebug( "read m3u filename " + filename ); 1113 // qDebug( "read m3u filename " + filename );
1114 1114
1115 Om3u *m3uList; 1115 Om3u *m3uList;
1116 QString s, name; 1116 QString s, name;
1117 m3uList = new Om3u( filename, IO_ReadOnly ); 1117 m3uList = new Om3u( filename, IO_ReadOnly );
1118 m3uList->readM3u(); 1118 m3uList->readM3u();
1119 DocLnk lnk; 1119 DocLnk lnk;
1120 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1120 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1121 s = *it; 1121 s = *it;
1122 // qDebug("reading "+ s); 1122 // qDebug("reading "+ s);
1123 if(s.left(4)=="http") { 1123 if(s.left(4)=="http") {
1124 lnk.setName( s ); //sets file name 1124 lnk.setName( s ); //sets file name
1125 lnk.setIcon("opieplayer2/musicfile"); 1125 lnk.setIcon("opieplayer2/musicfile");
1126 1126
1127 // if(s.right(4) != '.' || s.right(5) != '.') 1127 // if(s.right(4) != '.' || s.right(5) != '.')
1128 if(s.right(4) != '.' || s.right(5) != '.' ) 1128 if(s.right(4) != '.' || s.right(5) != '.' )
1129 if( s.right(1) != "/") 1129 if( s.right(1) != "/")
1130 lnk.setFile( s+"/"); //if url with no extension 1130 lnk.setFile( s+"/"); //if url with no extension
1131 else 1131 else
1132 lnk.setFile( s ); //sets file name 1132 lnk.setFile( s ); //sets file name
1133 1133
1134 } else { 1134 } else {
1135 // if( QFileInfo( s ).exists() ) { 1135 // if( QFileInfo( s ).exists() ) {
1136 lnk.setName( fullBaseName ( QFileInfo(s))); 1136 lnk.setName( fullBaseName ( QFileInfo(s)));
1137 // if(s.right(4) == '.') {//if regular file 1137 // if(s.right(4) == '.') {//if regular file
1138 if(s.left(1) != "/") { 1138 if(s.left(1) != "/") {
1139 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1139 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1140 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1140 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1141 lnk.setIcon("SoundPlayer"); 1141 lnk.setIcon("SoundPlayer");
1142 } else { 1142 } else {
1143 // qDebug("set link2 "+s); 1143 // qDebug("set link2 "+s);
1144 lnk.setFile( s); 1144 lnk.setFile( s);
1145 lnk.setIcon("SoundPlayer"); 1145 lnk.setIcon("SoundPlayer");
1146 } 1146 }
1147 } 1147 }
1148 d->selectedFiles->addToSelection( lnk ); 1148 d->selectedFiles->addToSelection( lnk );
1149 } 1149 }
1150 Config config( "OpiePlayer" ); 1150 Config config( "OpiePlayer" );
1151 config.setGroup( "PlayList" ); 1151 config.setGroup( "PlayList" );
1152 1152
1153 config.writeEntry("CurrentPlaylist",filename); 1153 config.writeEntry("CurrentPlaylist",filename);
1154 config.write(); 1154 config.write();
1155 currentPlayList=filename; 1155 currentPlayList=filename;
1156 1156
1157// m3uList->write(); 1157// m3uList->write();
1158 m3uList->close(); 1158 m3uList->close();
1159 if(m3uList) delete m3uList; 1159 if(m3uList) delete m3uList;
1160 1160
1161 d->selectedFiles->setSelectedItem( s); 1161 d->selectedFiles->setSelectedItem( s);
1162 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1162 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1163 1163
1164} 1164}
1165 1165
1166/* 1166/*
1167reads pls and adds files/urls to playlist */ 1167reads pls and adds files/urls to playlist */
1168void PlayListWidget::readPls( const QString &filename ) { 1168void PlayListWidget::readPls( const QString &filename ) {
1169 1169
1170 // qDebug( "pls filename is " + filename ); 1170 // qDebug( "pls filename is " + filename );
1171 Om3u *m3uList; 1171 Om3u *m3uList;
1172 QString s, name; 1172 QString s, name;
1173 m3uList = new Om3u( filename, IO_ReadOnly ); 1173 m3uList = new Om3u( filename, IO_ReadOnly );
1174 m3uList->readPls(); 1174 m3uList->readPls();
1175 1175
1176 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1176 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1177 s = *it; 1177 s = *it;
1178 // s.replace( QRegExp( "%20" )," " ); 1178 // s.replace( QRegExp( "%20" )," " );
1179 DocLnk lnk( s ); 1179 DocLnk lnk( s );
1180 QFileInfo f( s ); 1180 QFileInfo f( s );
1181 QString name = fullBaseName ( f); 1181 QString name = fullBaseName ( f);
1182 1182
1183 if( name.left( 4 ) == "http" ) { 1183 if( name.left( 4 ) == "http" ) {
1184 name = s.right( s.length() - 7); 1184 name = s.right( s.length() - 7);
1185 } else { 1185 } else {
1186 name = s; 1186 name = s;
1187 } 1187 }
1188 1188
1189 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1189 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1190 1190
1191 lnk.setName( name ); 1191 lnk.setName( name );
1192 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1192 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1193 lnk.setFile( s ); 1193 lnk.setFile( s );
1194 } else { //if its a url 1194 } else { //if its a url
1195 if( name.right( 1 ).find( '/' ) == -1) { 1195 if( name.right( 1 ).find( '/' ) == -1) {
1196 s += "/"; 1196 s += "/";
1197 } 1197 }
1198 lnk.setFile( s ); 1198 lnk.setFile( s );
1199 } 1199 }
1200 lnk.setType( "audio/x-mpegurl" ); 1200 lnk.setType( "audio/x-mpegurl" );
1201 1201
1202 lnk.writeLink(); 1202 lnk.writeLink();
1203 d->selectedFiles->addToSelection( lnk ); 1203 d->selectedFiles->addToSelection( lnk );
1204 } 1204 }
1205 1205
1206 m3uList->close(); 1206 m3uList->close();
1207 if(m3uList) delete m3uList; 1207 if(m3uList) delete m3uList;
1208} 1208}
1209 1209
1210/* 1210/*
1211 writes current playlist to current m3u file */ 1211 writes current playlist to current m3u file */
1212void PlayListWidget::writeCurrentM3u() { 1212void PlayListWidget::writeCurrentM3u() {
1213 // qDebug("writing to current m3u"); 1213 // qDebug("writing to current m3u");
1214 Config cfg( "OpiePlayer" ); 1214 Config cfg( "OpiePlayer" );
1215 cfg.setGroup("PlayList"); 1215 cfg.setGroup("PlayList");
1216 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 1216 currentPlayList = cfg.readEntry("CurrentPlaylist","");
1217 Om3u *m3uList; 1217 Om3u *m3uList;
1218 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); 1218 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
1219 1219
1220 if( d->selectedFiles->first()) { 1220 if( d->selectedFiles->first()) {
1221 do { 1221 do {
1222 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1222 // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1223 m3uList->add( d->selectedFiles->current()->file() ); 1223 m3uList->add( d->selectedFiles->current()->file() );
1224 } 1224 }
1225 while ( d->selectedFiles->next() ); 1225 while ( d->selectedFiles->next() );
1226 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1226 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1227 m3uList->write(); 1227 m3uList->write();
1228 m3uList->close(); 1228 m3uList->close();
1229 1229
1230 if(m3uList) delete m3uList; 1230 if(m3uList) delete m3uList;
1231 } 1231 }
1232} 1232}
1233 1233
1234 /* 1234 /*
1235 writes current playlist to m3u file */ 1235 writes current playlist to m3u file */
1236void PlayListWidget::writem3u() { 1236void PlayListWidget::writem3u() {
1237 InputDialog *fileDlg; 1237 InputDialog *fileDlg;
1238 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1238 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1239 fileDlg->exec(); 1239 fileDlg->exec();
1240 QString name, filename, list; 1240 QString name, filename, list;
1241 Om3u *m3uList; 1241 Om3u *m3uList;
1242 1242
1243 if( fileDlg->result() == 1 ) { 1243 if( fileDlg->result() == 1 ) {
1244 name = fileDlg->text(); 1244 name = fileDlg->text();
1245 // qDebug( filename ); 1245 // qDebug( filename );
1246 if( name.find("/",0,true) != -1) {// assume they specify a file path 1246 if( name.find("/",0,true) != -1) {// assume they specify a file path
1247 filename = name; 1247 filename = name;
1248 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1248 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1249 } 1249 }
1250 else //otherwise dump it somewhere noticable 1250 else //otherwise dump it somewhere noticable
1251 filename = QPEApplication::documentDir() + "/" + name; 1251 filename = QPEApplication::documentDir() + "/" + name;
1252 1252
1253 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1253 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1254 filename += ".m3u"; 1254 filename += ".m3u";
1255 1255
1256 if( d->selectedFiles->first()) { 1256 if( d->selectedFiles->first()) {
1257 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 1257 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
1258 1258
1259 do { 1259 do {
1260 m3uList->add( d->selectedFiles->current()->file()); 1260 m3uList->add( d->selectedFiles->current()->file());
1261 } 1261 }
1262 while ( d->selectedFiles->next() ); 1262 while ( d->selectedFiles->next() );
1263 // qDebug( list ); 1263 // qDebug( list );
1264 m3uList->write(); 1264 m3uList->write();
1265 m3uList->close(); 1265 m3uList->close();
1266 if(m3uList) delete m3uList; 1266 if(m3uList) delete m3uList;
1267 1267
1268 if(fileDlg) delete fileDlg; 1268 if(fileDlg) delete fileDlg;
1269 1269
1270 DocLnk lnk; 1270 DocLnk lnk;
1271 lnk.setFile( filename); 1271 lnk.setFile( filename);
1272 lnk.setIcon("opieplayer2/playlist2"); 1272 lnk.setIcon("opieplayer2/playlist2");
1273 lnk.setName( name); //sets file name 1273 lnk.setName( name); //sets file name
1274 1274
1275 // qDebug(filename); 1275 // qDebug(filename);
1276 Config config( "OpiePlayer" ); 1276 Config config( "OpiePlayer" );
1277 config.setGroup( "PlayList" ); 1277 config.setGroup( "PlayList" );
1278 1278
1279 config.writeEntry("CurrentPlaylist",filename); 1279 config.writeEntry("CurrentPlaylist",filename);
1280 currentPlayList=filename; 1280 currentPlayList=filename;
1281 1281
1282 if(!lnk.writeLink()) { 1282 if(!lnk.writeLink()) {
1283 // qDebug("Writing doclink did not work"); 1283 // qDebug("Writing doclink did not work");
1284 } 1284 }
1285 1285
1286 setCaption(tr("OpiePlayer: ") + name); 1286 setCaption(tr("OpiePlayer: ") + name);
1287 } 1287 }
1288 } 1288 }
1289} 1289}
1290 1290
1291 1291
1292void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1292void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1293{ 1293{
1294 switch ( e->key() ) { 1294 switch ( e->key() ) {
1295////////////////////////////// Zaurus keys 1295////////////////////////////// Zaurus keys
1296 case Key_F9: //activity 1296 case Key_F9: //activity
1297// if(audioUI->isHidden()) 1297// if(audioUI->isHidden())
1298// audioUI->showMaximized(); 1298// audioUI->showMaximized();
1299 break; 1299 break;
1300 case Key_F10: //contacts 1300 case Key_F10: //contacts
1301// if( videoUI->isHidden()) 1301// if( videoUI->isHidden())
1302// videoUI->showMaximized(); 1302// videoUI->showMaximized();
1303 break; 1303 break;
1304 case Key_F11: //menu 1304 case Key_F11: //menu
1305 break; 1305 break;
1306 case Key_F12: //home 1306 case Key_F12: //home
1307// doBlank(); 1307// doBlank();
1308 break; 1308 break;
1309 case Key_F13: //mail 1309 case Key_F13: //mail
1310// doUnblank(); 1310// doUnblank();
1311 break; 1311 break;
1312 case Key_Q: //add to playlist 1312 case Key_Q: //add to playlist
1313 addSelected(); 1313 addSelected();
1314 break; 1314 break;
1315 case Key_R: //remove from playlist 1315 case Key_R: //remove from playlist
1316 removeSelected(); 1316 removeSelected();
1317 break; 1317 break;
1318// case Key_P: //play 1318// case Key_P: //play
1319// qDebug("Play"); 1319// qDebug("Play");
1320// playSelected(); 1320// playSelected();
1321// break; 1321// break;
1322 case Key_Space: 1322 case Key_Space:
1323// playSelected(); puh 1323// playSelected(); puh
1324 break; 1324 break;
1325 case Key_1: 1325 case Key_1:
1326 tabWidget->setCurrentPage(0); 1326 tabWidget->setCurrentPage(0);
1327 break; 1327 break;
1328 case Key_2: 1328 case Key_2:
1329 tabWidget->setCurrentPage(1); 1329 tabWidget->setCurrentPage(1);
1330 break; 1330 break;
1331 case Key_3: 1331 case Key_3:
1332 tabWidget->setCurrentPage(2); 1332 tabWidget->setCurrentPage(2);
1333 break; 1333 break;
1334 case Key_4: 1334 case Key_4:
1335 tabWidget->setCurrentPage(3); 1335 tabWidget->setCurrentPage(3);
1336 break; 1336 break;
1337 case Key_Down: 1337 case Key_Down:
1338 if ( !d->selectedFiles->next() ) 1338 if ( !d->selectedFiles->next() )
1339 d->selectedFiles->first(); 1339 d->selectedFiles->first();
1340 1340
1341 break; 1341 break;
1342 case Key_Up: 1342 case Key_Up:
1343 if ( !d->selectedFiles->prev() ) 1343 if ( !d->selectedFiles->prev() )
1344 // d->selectedFiles->last(); 1344 // d->selectedFiles->last();
1345 1345
1346 break; 1346 break;
1347 1347
1348 } 1348 }
1349} 1349}
1350 1350
1351void PlayListWidget::keyPressEvent( QKeyEvent *) 1351void PlayListWidget::keyPressEvent( QKeyEvent *)
1352{ 1352{
1353// qDebug("Key press"); 1353// qDebug("Key press");
1354// switch ( e->key() ) { 1354// switch ( e->key() ) {
1355// ////////////////////////////// Zaurus keys 1355// ////////////////////////////// Zaurus keys
1356// case Key_A: //add to playlist 1356// case Key_A: //add to playlist
1357// qDebug("Add"); 1357// qDebug("Add");
1358// addSelected(); 1358// addSelected();
1359// break; 1359// break;
1360// case Key_R: //remove from playlist 1360// case Key_R: //remove from playlist
1361// removeSelected(); 1361// removeSelected();
1362// break; 1362// break;
1363// case Key_P: //play 1363// case Key_P: //play
1364// qDebug("Play"); 1364// qDebug("Play");
1365// playSelected(); 1365// playSelected();
1366// break; 1366// break;
1367// case Key_Space: 1367// case Key_Space:
1368// qDebug("Play"); 1368// qDebug("Play");
1369// playSelected(); 1369// playSelected();
1370// break; 1370// break;
1371// } 1371// }
1372} 1372}
1373 1373
1374void PlayListWidget::doBlank() { 1374void PlayListWidget::doBlank() {
1375 // qDebug("do blanking"); 1375 // TODO: why do we blank this way, why don't we use ODevice or ScreenSaver?
1376#ifdef QT_QWS_DEVFS
1377 fd=open("/dev/fb/0",O_RDWR);
1378#else
1376 fd=open("/dev/fb0",O_RDWR); 1379 fd=open("/dev/fb0",O_RDWR);
1380#endif
1377 if (fd != -1) { 1381 if (fd != -1) {
1378 ioctl(fd,FBIOBLANK,1); 1382 ioctl(fd,FBIOBLANK,1);
1379 // close(fd); 1383 // close(fd);
1380 } 1384 }
1381} 1385}
1382 1386
1383void PlayListWidget::doUnblank() { 1387void PlayListWidget::doUnblank() {
1384 // this crashes opieplayer with a segfault 1388 // this crashes opieplayer with a segfault
1385 // int fd; 1389 // int fd;
1386 // fd=open("/dev/fb0",O_RDWR); 1390 // fd=open("/dev/fb0",O_RDWR);
1387 // qDebug("do unblanking"); 1391 // qDebug("do unblanking");
1388 if (fd != -1) { 1392 if (fd != -1) {
1389 ioctl(fd,FBIOBLANK,0); 1393 ioctl(fd,FBIOBLANK,0);
1390 close(fd); 1394 close(fd);
1391 } 1395 }
1392 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1396 QCopEnvelope h("QPE/System", "setBacklight(int)");
1393 h <<-3;// v[1]; // -3 Force on 1397 h <<-3;// v[1]; // -3 Force on
1394} 1398}
1395 1399
1396void PlayListWidget::populateSkinsMenu() { 1400void PlayListWidget::populateSkinsMenu() {
1397 int item = 0; 1401 int item = 0;
1398 defaultSkinIndex = 0; 1402 defaultSkinIndex = 0;
1399 QString skinName; 1403 QString skinName;
1400 Config cfg( "OpiePlayer" ); 1404 Config cfg( "OpiePlayer" );
1401 cfg.setGroup("Options" ); 1405 cfg.setGroup("Options" );
1402 QString skin = cfg.readEntry( "Skin", "default" ); 1406 QString skin = cfg.readEntry( "Skin", "default" );
1403 1407
1404 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1408 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1405 skinsDir.setFilter( QDir::Dirs ); 1409 skinsDir.setFilter( QDir::Dirs );
1406 skinsDir.setSorting(QDir::Name ); 1410 skinsDir.setSorting(QDir::Name );
1407 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1411 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1408 QFileInfoListIterator it( *skinslist ); 1412 QFileInfoListIterator it( *skinslist );
1409 QFileInfo *fi; 1413 QFileInfo *fi;
1410 while ( ( fi = it.current() ) ) { 1414 while ( ( fi = it.current() ) ) {
1411 skinName = fi->fileName(); 1415 skinName = fi->fileName();
1412 // qDebug( fi->fileName() ); 1416 // qDebug( fi->fileName() );
1413 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1417 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1414 item = skinsMenu->insertItem( fi->fileName() ) ; 1418 item = skinsMenu->insertItem( fi->fileName() ) ;
1415 } 1419 }
1416 if( skinName == "default" ) { 1420 if( skinName == "default" ) {
1417 defaultSkinIndex = item; 1421 defaultSkinIndex = item;
1418 } 1422 }
1419 if( skinName == skin ) { 1423 if( skinName == skin ) {
1420 skinsMenu->setItemChecked( item, TRUE ); 1424 skinsMenu->setItemChecked( item, TRUE );
1421 } 1425 }
1422 ++it; 1426 ++it;
1423 } 1427 }
1424} 1428}
1425 1429
1426void PlayListWidget::skinsMenuActivated( int item ) { 1430void PlayListWidget::skinsMenuActivated( int item ) {
1427 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1431 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1428 skinsMenu->setItemChecked( i, FALSE ); 1432 skinsMenu->setItemChecked( i, FALSE );
1429 } 1433 }
1430 skinsMenu->setItemChecked( item, TRUE ); 1434 skinsMenu->setItemChecked( item, TRUE );
1431 1435
1432 Config cfg( "OpiePlayer" ); 1436 Config cfg( "OpiePlayer" );
1433 cfg.setGroup("Options"); 1437 cfg.setGroup("Options");
1434 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1438 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1435} 1439}
1436 1440
1437void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1441void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1438 // qDebug("qcop message "+msg ); 1442 // qDebug("qcop message "+msg );
1439 QDataStream stream ( data, IO_ReadOnly ); 1443 QDataStream stream ( data, IO_ReadOnly );
1440 if ( msg == "play()" ) { //plays current selection 1444 if ( msg == "play()" ) { //plays current selection
1441 btnPlay( true); 1445 btnPlay( true);
1442 } else if ( msg == "stop()" ) { 1446 } else if ( msg == "stop()" ) {
1443 mediaPlayerState->setPlaying( false); 1447 mediaPlayerState->setPlaying( false);
1444 } else if ( msg == "togglePause()" ) { 1448 } else if ( msg == "togglePause()" ) {
1445 mediaPlayerState->togglePaused(); 1449 mediaPlayerState->togglePaused();
1446 } else if ( msg == "next()" ) { //select next in lis 1450 } else if ( msg == "next()" ) { //select next in lis
1447 mediaPlayerState->setNext(); 1451 mediaPlayerState->setNext();
1448 } else if ( msg == "prev()" ) { //select previous in list 1452 } else if ( msg == "prev()" ) { //select previous in list
1449 mediaPlayerState->setPrev(); 1453 mediaPlayerState->setPrev();
1450 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1454 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1451 mediaPlayerState->toggleLooping(); 1455 mediaPlayerState->toggleLooping();
1452 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1456 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1453 mediaPlayerState->toggleShuffled(); 1457 mediaPlayerState->toggleShuffled();
1454 } else if ( msg == "volUp()" ) { //volume more 1458 } else if ( msg == "volUp()" ) { //volume more
1455 // emit moreClicked(); 1459 // emit moreClicked();
1456 // emit moreReleased(); 1460 // emit moreReleased();
1457 } else if ( msg == "volDown()" ) { //volume less 1461 } else if ( msg == "volDown()" ) { //volume less
1458 // emit lessClicked(); 1462 // emit lessClicked();
1459 // emit lessReleased(); 1463 // emit lessReleased();
1460 } else if ( msg == "play(QString)" ) { //play this now 1464 } else if ( msg == "play(QString)" ) { //play this now
1461 QString file; 1465 QString file;
1462 stream >> file; 1466 stream >> file;
1463 setDocumentEx( (const QString &) file); 1467 setDocumentEx( (const QString &) file);
1464 } else if ( msg == "add(QString)" ) { //add to playlist 1468 } else if ( msg == "add(QString)" ) { //add to playlist
1465 QString file; 1469 QString file;
1466 stream >> file; 1470 stream >> file;
1467 QFileInfo fileInfo(file); 1471 QFileInfo fileInfo(file);
1468 DocLnk lnk; 1472 DocLnk lnk;
1469 lnk.setName( fileInfo.baseName() ); //sets name 1473 lnk.setName( fileInfo.baseName() ); //sets name
1470 lnk.setFile( file ); //sets file name 1474 lnk.setFile( file ); //sets file name
1471 addToSelection( lnk ); 1475 addToSelection( lnk );
1472 } else if ( msg == "rem(QString)" ) { //remove from playlist 1476 } else if ( msg == "rem(QString)" ) { //remove from playlist
1473 QString file; 1477 QString file;
1474 stream >> file; 1478 stream >> file;
1475 } else if ( msg == "setDocument(QString)" ) { //loop or not loop 1479 } else if ( msg == "setDocument(QString)" ) { //loop or not loop
1476 QCopEnvelope h("QPE/Application/opieplayer", "raise()"); 1480 QCopEnvelope h("QPE/Application/opieplayer", "raise()");
1477 } 1481 }
1478} 1482}