summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-08-28 19:53:11 (UTC)
committer llornkcor <llornkcor>2005-08-28 19:53:11 (UTC)
commitf680479965bf13285a955873c48db47bd0c935d3 (patch) (unidiff)
tree58945d235215685b316c00b62d951bd0b6d4df95
parent43217700cc9b23519776a27661fbf0c29a7d100d (diff)
downloadopie-f680479965bf13285a955873c48db47bd0c935d3.zip
opie-f680479965bf13285a955873c48db47bd0c935d3.tar.gz
opie-f680479965bf13285a955873c48db47bd0c935d3.tar.bz2
podcast! support.. 1st installment. needs improvements
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp344
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h10
-rw-r--r--core/multimedia/opieplayer/rssparser.cpp201
-rw-r--r--core/multimedia/opieplayer/rssparser.h122
4 files changed, 567 insertions, 110 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index c0a0029..146dbb6 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1464 +1,1594 @@
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// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22 22
23#include "playlistselection.h" 23#include "playlistselection.h"
24#include "playlistwidget.h" 24#include "playlistwidget.h"
25#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
26#include "inputDialog.h" 26#include "inputDialog.h"
27#include "audiowidget.h" 27#include "audiowidget.h"
28#include "videowidget.h" 28#include "videowidget.h"
29#include "rssparser.h"
29 30
31#include <qpe/process.h>
32
33#include <qvector.h>
34#include <qxml.h>
30/* OPIE */ 35/* OPIE */
31#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
32#include <qpe/qpemenubar.h> 37#include <qpe/qpemenubar.h>
33#include <qpe/lnkproperties.h> 38#include <qpe/lnkproperties.h>
34#include <opie2/odebug.h> 39#include <opie2/odebug.h>
35#include <opie2/oresource.h> 40#include <opie2/oresource.h>
36 41
37/* QT */ 42/* QT */
38#include <qtoolbar.h> 43#include <qtoolbar.h>
39#include <qaction.h> 44#include <qaction.h>
40#include <qlayout.h> 45#include <qlayout.h>
41#include <qmessagebox.h> 46#include <qmessagebox.h>
42//#include <qtimer.h> 47//#include <qtimer.h>
43 48
44/* STD */ 49/* STD */
45#include <stdlib.h> 50#include <stdlib.h>
46 51
47#include <unistd.h> 52#include <unistd.h>
48#include <sys/file.h> 53#include <sys/file.h>
49#include <sys/ioctl.h> 54#include <sys/ioctl.h>
50#include <sys/soundcard.h> 55#include <sys/soundcard.h>
51 56
52// for setBacklight() 57// for setBacklight()
53#include <linux/fb.h> 58#include <linux/fb.h>
54#include <sys/types.h> 59#include <sys/types.h>
55#include <sys/stat.h> 60#include <sys/stat.h>
56#include <stdlib.h> 61#include <stdlib.h>
57 62
58#define BUTTONS_ON_TOOLBAR 63#define BUTTONS_ON_TOOLBAR
59#define SIDE_BUTTONS 64#define SIDE_BUTTONS
60#define CAN_SAVE_LOAD_PLAYLISTS 65#define CAN_SAVE_LOAD_PLAYLISTS
61 66
62extern AudioWidget *audioUI; 67extern AudioWidget *audioUI;
63extern VideoWidget *videoUI; 68extern VideoWidget *videoUI;
64extern MediaPlayerState *mediaPlayerState; 69extern MediaPlayerState *mediaPlayerState;
65 70
66static inline QString fullBaseName ( const QFileInfo &fi ) 71static inline QString fullBaseName ( const QFileInfo &fi )
67{ 72{
68 QString str = fi. fileName ( ); 73 QString str = fi. fileName ( );
69 return str. left ( str. findRev ( '.' )); 74 return str. left ( str. findRev ( '.' ));
70} 75}
71 76
72 77
73QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; 78QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
74// class myFileSelector { 79// class myFileSelector {
75 80
76// }; 81// };
77class PlayListWidgetPrivate { 82class PlayListWidgetPrivate {
78public: 83public:
79 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 84 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
80 QFrame *playListFrame; 85 QFrame *playListFrame;
81 FileSelector *files; 86 FileSelector *files;
82 PlayListSelection *selectedFiles; 87 PlayListSelection *selectedFiles;
83 bool setDocumentUsed; 88 bool setDocumentUsed;
84 DocLnk *current; 89 DocLnk *current;
85}; 90};
86 91
87 92
88class ToolButton : public QToolButton { 93class ToolButton : public QToolButton {
89public: 94public:
90 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 95 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
91 : QToolButton( parent, name ) { 96 : QToolButton( parent, name ) {
92 setTextLabel( name ); 97 setTextLabel( name );
93 setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ); 98 setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
94 setAutoRaise( TRUE ); 99 setAutoRaise( TRUE );
95 setUsesBigPixmap( qApp->desktop()->size().width() > 330 ); 100 setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
96 setFocusPolicy( QWidget::NoFocus ); 101 setFocusPolicy( QWidget::NoFocus );
97 setToggleButton( t ); 102 setToggleButton( t );
98 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 103 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
99 QPEMenuToolFocusManager::manager()->addWidget( this ); 104 QPEMenuToolFocusManager::manager()->addWidget( this );
100 } 105 }
101}; 106};
102 107
103 108
104class MenuItem : public QAction { 109class MenuItem : public QAction {
105public: 110public:
106 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 111 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
107 : QAction( text, QString::null, 0, 0 ) { 112 : QAction( text, QString::null, 0, 0 ) {
108 connect( this, SIGNAL( activated() ), handler, slot ); 113 connect( this, SIGNAL( activated() ), handler, slot );
109 addTo( parent ); 114 addTo( parent );
110 } 115 }
111}; 116};
112 117
113 118
114PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 119PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
115 : QMainWindow( parent, name, fl ) { 120 : QMainWindow( parent, name, fl ) {
116 121
117 d = new PlayListWidgetPrivate; 122 d = new PlayListWidgetPrivate;
118 d->setDocumentUsed = FALSE; 123 d->setDocumentUsed = FALSE;
119 d->current = NULL; 124 d->current = NULL;
120 fromSetDocument = FALSE; 125 fromSetDocument = FALSE;
121 insanityBool=FALSE; 126 insanityBool=FALSE;
122 audioScan = FALSE; 127 audioScan = FALSE;
123 videoScan = FALSE; 128 videoScan = FALSE;
124// menuTimer = new QTimer( this ,"menu timer"), 129// menuTimer = new QTimer( this ,"menu timer"),
125// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 130// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
126 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 131 channel = new QCopChannel( "QPE/Application/opieplayer", this );
127 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 132 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
128 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 133 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
129 134
130 setBackgroundMode( PaletteButton ); 135 setBackgroundMode( PaletteButton );
131 136
132 setCaption( tr("OpiePlayer") ); 137 setCaption( tr("OpiePlayer") );
133 setIcon( Opie::Core::OResource::loadPixmap( "opieplayer/MPEGPlayer", Opie::Core::OResource::SmallIcon ) ); 138 setIcon( Opie::Core::OResource::loadPixmap( "opieplayer/MPEGPlayer", Opie::Core::OResource::SmallIcon ) );
134 139
135 setToolBarsMovable( FALSE ); 140 setToolBarsMovable( FALSE );
136 141
137 // Create Toolbar 142 // Create Toolbar
138 QToolBar *toolbar = new QToolBar( this ); 143 QToolBar *toolbar = new QToolBar( this );
139 toolbar->setHorizontalStretchable( TRUE ); 144 toolbar->setHorizontalStretchable( TRUE );
140 145
141 // Create Menubar 146 // Create Menubar
142 QMenuBar *menu = new QMenuBar( toolbar ); 147 QMenuBar *menu = new QMenuBar( toolbar );
143 menu->setMargin( 0 ); 148 menu->setMargin( 0 );
144 149
145 QToolBar *bar = new QToolBar( this ); 150 QToolBar *bar = new QToolBar( this );
146 bar->setLabel( tr( "Play Operations" ) ); 151 bar->setLabel( tr( "Play Operations" ) );
147// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 152// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
148// this , SLOT( addSelected()) ); 153// this , SLOT( addSelected()) );
149 tbDeletePlaylist = new QPushButton( Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon),"",bar,"close"); 154 tbDeletePlaylist = new QPushButton( Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon),"",bar,"close");
150 tbDeletePlaylist->setFlat(TRUE); 155 tbDeletePlaylist->setFlat(TRUE);
151 156
152 tbDeletePlaylist->setFixedSize(20,20); 157 tbDeletePlaylist->setFixedSize(20,20);
153 158
154 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 159 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
155 this , SLOT(addSelected()) ); 160 this , SLOT(addSelected()) );
156 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 161 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
157 this , SLOT(removeSelected()) ); 162 this , SLOT(removeSelected()) );
158// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); 163// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE );
159 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 164 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
160 this , SLOT( btnPlay(bool) ), TRUE ); 165 this , SLOT( btnPlay(bool) ), TRUE );
161 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 166 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
162 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 167 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
163 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 168 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
164 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 169 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
165 tbDeletePlaylist->hide(); 170 tbDeletePlaylist->hide();
166 171
167 QPopupMenu *pmPlayList = new QPopupMenu( this ); 172 QPopupMenu *pmPlayList = new QPopupMenu( this );
168 menu->insertItem( tr( "File" ), pmPlayList ); 173 menu->insertItem( tr( "File" ), pmPlayList );
169 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 174 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
170 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 175 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
171 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 176 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
172 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 177 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
173 pmPlayList->insertSeparator(-1); 178 pmPlayList->insertSeparator(-1);
174 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 179 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
175 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 180 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
176 pmPlayList->insertSeparator(-1); 181 pmPlayList->insertSeparator(-1);
177 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 182 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
178 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 183 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
179 184
180 QPopupMenu *pmView = new QPopupMenu( this ); 185 QPopupMenu *pmView = new QPopupMenu( this );
181 menu->insertItem( tr( "View" ), pmView ); 186 menu->insertItem( tr( "View" ), pmView );
182 187
183 fullScreenButton = new QAction(tr("Full Screen"), Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), 188 fullScreenButton = new QAction(tr("Full Screen"), Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon),
184 QString::null, 0, this, 0); 189 QString::null, 0, this, 0);
185 fullScreenButton->addTo(pmView); 190 fullScreenButton->addTo(pmView);
186 scaleButton = new QAction(tr("Scale"), Opie::Core::OResource::loadPixmap("opieplayer/scale", Opie::Core::OResource::SmallIcon), 191 scaleButton = new QAction(tr("Scale"), Opie::Core::OResource::loadPixmap("opieplayer/scale", Opie::Core::OResource::SmallIcon),
187 QString::null, 0, this, 0); 192 QString::null, 0, this, 0);
188 scaleButton->addTo(pmView); 193 scaleButton->addTo(pmView);
189 194
190 195
191 skinsMenu = new QPopupMenu( this ); 196 skinsMenu = new QPopupMenu( this );
192 menu->insertItem( tr( "Skins" ), skinsMenu ); 197 menu->insertItem( tr( "Skins" ), skinsMenu );
193 skinsMenu->isCheckable(); 198 skinsMenu->isCheckable();
194 connect( skinsMenu, SIGNAL( activated(int) ) , 199 connect( skinsMenu, SIGNAL( activated(int) ) ,
195 this, SLOT( skinsMenuActivated(int) ) ); 200 this, SLOT( skinsMenuActivated(int) ) );
196 populateSkinsMenu(); 201 populateSkinsMenu();
197 202
198 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 203 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
199 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 204 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
200 205
201 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 206 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
202 207
203 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 208 tabWidget = new QTabWidget( hbox6, "tabWidget" );
204// tabWidget->setTabShape(QTabWidget::Triangular); 209// tabWidget->setTabShape(QTabWidget::Triangular);
205 210
206 QWidget *pTab; 211 QWidget *pTab;
207 pTab = new QWidget( tabWidget, "pTab" ); 212 pTab = new QWidget( tabWidget, "pTab" );
208// playlistView = new QListView( pTab, "playlistview" ); 213// playlistView = new QListView( pTab, "playlistview" );
209// playlistView->setMinimumSize(236,260); 214// playlistView->setMinimumSize(236,260);
210 tabWidget->insertTab( pTab,"Playlist"); 215 tabWidget->insertTab( pTab,"Playlist");
211 216
212 217
213 // Add the playlist area 218 // Add the playlist area
214 219
215 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 220 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
216 d->playListFrame = vbox3; 221 d->playListFrame = vbox3;
217 222
218 QGridLayout *layoutF = new QGridLayout( pTab ); 223 QGridLayout *layoutF = new QGridLayout( pTab );
219 layoutF->setSpacing( 2); 224 layoutF->setSpacing( 2);
220 layoutF->setMargin( 2); 225 layoutF->setMargin( 2);
221 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); 226 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
222 227
223 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 228 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
224 229
225 d->selectedFiles = new PlayListSelection( hbox2); 230 d->selectedFiles = new PlayListSelection( hbox2);
226 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 231 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
227 232
228 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 233 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
229 234
230 235
231 236
232 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 237 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
233 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 238 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
234 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 239 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
235 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 240 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
236 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 241 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
237 242
238 QWidget *aTab; 243 QWidget *aTab;
239 aTab = new QWidget( tabWidget, "aTab" ); 244 aTab = new QWidget( tabWidget, "aTab" );
240 audioView = new QListView( aTab, "Audioview" ); 245 audioView = new QListView( aTab, "Audioview" );
241 246
242 QGridLayout *layoutA = new QGridLayout( aTab ); 247 QGridLayout *layoutA = new QGridLayout( aTab );
243 layoutA->setSpacing( 2); 248 layoutA->setSpacing( 2);
244 layoutA->setMargin( 2); 249 layoutA->setMargin( 2);
245 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 250 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 );
246 251
247 audioView->addColumn( tr("Title"),-1); 252 audioView->addColumn( tr("Title"),-1);
248 audioView->addColumn(tr("Size"), -1); 253 audioView->addColumn(tr("Size"), -1);
249 audioView->addColumn(tr("Media"),-1); 254 audioView->addColumn(tr("Media"),-1);
250 audioView->addColumn( tr( "Path" ), -1 ); 255 audioView->addColumn( tr( "Path" ), -1 );
251 256
252 audioView->setColumnAlignment(1, Qt::AlignRight); 257 audioView->setColumnAlignment(1, Qt::AlignRight);
253 audioView->setColumnAlignment(2, Qt::AlignRight); 258 audioView->setColumnAlignment(2, Qt::AlignRight);
254 audioView->setAllColumnsShowFocus(TRUE); 259 audioView->setAllColumnsShowFocus(TRUE);
255 260
256 audioView->setMultiSelection( TRUE ); 261 audioView->setMultiSelection( TRUE );
257 audioView->setSelectionMode( QListView::Extended); 262 audioView->setSelectionMode( QListView::Extended);
258 audioView->setSorting( 3, TRUE ); 263 audioView->setSorting( 3, TRUE );
259 264
260 tabWidget->insertTab(aTab,tr("Audio")); 265 tabWidget->insertTab(aTab,tr("Audio"));
261 266
262 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 267 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
263 268
264// audioView 269// audioView
265// populateAudioView(); 270// populateAudioView();
266// videowidget 271// videowidget
267 272
268 QWidget *vTab; 273 QWidget *vTab;
269 vTab = new QWidget( tabWidget, "vTab" ); 274 vTab = new QWidget( tabWidget, "vTab" );
270 videoView = new QListView( vTab, "Videoview" ); 275 videoView = new QListView( vTab, "Videoview" );
271 276
272 QGridLayout *layoutV = new QGridLayout( vTab ); 277 QGridLayout *layoutV = new QGridLayout( vTab );
273 layoutV->setSpacing( 2); 278 layoutV->setSpacing( 2);
274 layoutV->setMargin( 2); 279 layoutV->setMargin( 2);
275 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 280 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
276 281
277 videoView->addColumn(tr("Title"),-1); 282 videoView->addColumn(tr("Title"),-1);
278 videoView->addColumn(tr("Size"),-1); 283 videoView->addColumn(tr("Size"),-1);
279 videoView->addColumn(tr("Media"),-1); 284 videoView->addColumn(tr("Media"),-1);
280 videoView->addColumn(tr( "Path" ), -1 ); 285 videoView->addColumn(tr( "Path" ), -1 );
281 videoView->setColumnAlignment(1, Qt::AlignRight); 286 videoView->setColumnAlignment(1, Qt::AlignRight);
282 videoView->setColumnAlignment(2, Qt::AlignRight); 287 videoView->setColumnAlignment(2, Qt::AlignRight);
283 videoView->setAllColumnsShowFocus(TRUE); 288 videoView->setAllColumnsShowFocus(TRUE);
284 videoView->setMultiSelection( TRUE ); 289 videoView->setMultiSelection( TRUE );
285 videoView->setSelectionMode( QListView::Extended); 290 videoView->setSelectionMode( QListView::Extended);
286 291
287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 292 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
288 293
289 tabWidget->insertTab( vTab,tr("Video")); 294 tabWidget->insertTab( vTab,tr("Video"));
290 295
291 QWidget *LTab; 296 QWidget *LTab;
292 LTab = new QWidget( tabWidget, "LTab" ); 297 LTab = new QWidget( tabWidget, "LTab" );
293 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); 298 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE);
294 299
295 QGridLayout *layoutL = new QGridLayout( LTab ); 300 QGridLayout *layoutL = new QGridLayout( LTab );
296 layoutL->setSpacing( 2); 301 layoutL->setSpacing( 2);
297 layoutL->setMargin( 2); 302 layoutL->setMargin( 2);
298 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 303 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
299 304
300 tabWidget->insertTab(LTab,tr("Lists")); 305 tabWidget->insertTab(LTab,tr("Lists"));
301 306
302 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 307 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
303 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 308 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
304 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 309 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
305 310
306 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 311 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
307 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); 312 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) );
308 313
309 314
310///audioView 315///audioView
311 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 316 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
312 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 317 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
313 318
314 connect( audioView, SIGNAL( returnPressed(QListViewItem*)), 319 connect( audioView, SIGNAL( returnPressed(QListViewItem*)),
315 this,SLOT( playIt(QListViewItem*)) ); 320 this,SLOT( playIt(QListViewItem*)) );
316 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 321 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
317 322
318 323
319//videoView 324//videoView
320 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 325 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
321 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); 326 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) );
322 connect( videoView, SIGNAL( returnPressed(QListViewItem*)), 327 connect( videoView, SIGNAL( returnPressed(QListViewItem*)),
323 this,SLOT( playIt(QListViewItem*)) ); 328 this,SLOT( playIt(QListViewItem*)) );
324 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); 329 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) );
325 330
326//playlists 331//playlists
327 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); 332 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) );
328 333
329 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 334 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
330 335
331 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); 336 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) );
332 337
333 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); 338 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) );
334 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); 339 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) );
335 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); 340 connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) );
336 341
337 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); 342 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) );
338 343
339 setCentralWidget( vbox5 ); 344 setCentralWidget( vbox5 );
340 345
341 Config cfg( "OpiePlayer" ); 346 Config cfg( "OpiePlayer" );
342 readConfig( cfg ); 347 readConfig( cfg );
343 348
344 currentPlayList = cfg.readEntry("CurrentPlaylist","default"); 349 currentPlayList = cfg.readEntry("CurrentPlaylist","default");
345 loadList(DocLnk( currentPlayList)); 350 loadList(DocLnk( currentPlayList));
346 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); 351 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
347 352
348 initializeStates(); 353 initializeStates();
349} 354}
350 355
351 356
352PlayListWidget::~PlayListWidget() { 357PlayListWidget::~PlayListWidget() {
353 Config cfg( "OpiePlayer" ); 358 Config cfg( "OpiePlayer" );
354 writeConfig( cfg ); 359 writeConfig( cfg );
355 360
356 if ( d->current ) 361 if ( d->current )
357 delete d->current; 362 delete d->current;
358 if(d) delete d; 363 if(d) delete d;
359} 364}
360 365
361 366
362void PlayListWidget::initializeStates() { 367void PlayListWidget::initializeStates() {
363 368
364 d->tbPlay->setOn( mediaPlayerState->playing() ); 369 d->tbPlay->setOn( mediaPlayerState->playing() );
365 d->tbLoop->setOn( mediaPlayerState->looping() ); 370 d->tbLoop->setOn( mediaPlayerState->looping() );
366 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 371 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
367 setPlaylist( true); 372 setPlaylist( true);
368} 373}
369 374
370 375
371void PlayListWidget::readConfig( Config& cfg ) { 376void PlayListWidget::readConfig( Config& cfg ) {
372 cfg.setGroup("PlayList"); 377 cfg.setGroup("PlayList");
373 QString currentString = cfg.readEntry("current", "" ); 378 QString currentString = cfg.readEntry("current", "" );
374 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 379 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
375 for ( int i = 0; i < noOfFiles; i++ ) { 380 for ( int i = 0; i < noOfFiles; i++ ) {
376 QString entryName; 381 QString entryName;
377 entryName.sprintf( "File%i", i + 1 ); 382 entryName.sprintf( "File%i", i + 1 );
378 QString linkFile = cfg.readEntry( entryName ); 383 QString linkFile = cfg.readEntry( entryName );
379 DocLnk lnk( linkFile ); 384 DocLnk lnk( linkFile );
380 if ( lnk.isValid() ) { 385 if ( lnk.isValid() ) {
381 d->selectedFiles->addToSelection( lnk ); 386 d->selectedFiles->addToSelection( lnk );
382 } 387 }
383 } 388 }
384 d->selectedFiles->setSelectedItem( currentString); 389 d->selectedFiles->setSelectedItem( currentString);
385} 390}
386 391
387 392
388void PlayListWidget::writeConfig( Config& cfg ) const { 393void PlayListWidget::writeConfig( Config& cfg ) const {
389 394
390 d->selectedFiles->writeCurrent( cfg); 395 d->selectedFiles->writeCurrent( cfg);
391 cfg.setGroup("PlayList"); 396 cfg.setGroup("PlayList");
392 int noOfFiles = 0; 397 int noOfFiles = 0;
393 d->selectedFiles->first(); 398 d->selectedFiles->first();
394 do { 399 do {
395 const DocLnk *lnk = d->selectedFiles->current(); 400 const DocLnk *lnk = d->selectedFiles->current();
396 if ( lnk ) { 401 if ( lnk ) {
397 QString entryName; 402 QString entryName;
398 entryName.sprintf( "File%i", noOfFiles + 1 ); 403 entryName.sprintf( "File%i", noOfFiles + 1 );
399// odebug << entryName << oendl; 404// odebug << entryName << oendl;
400 cfg.writeEntry( entryName, lnk->linkFile() ); 405 cfg.writeEntry( entryName, lnk->linkFile() );
401 // if this link does exist, add it so we have the file 406 // if this link does exist, add it so we have the file
402 // next time... 407 // next time...
403 if ( !QFile::exists( lnk->linkFile() ) ) { 408 if ( !QFile::exists( lnk->linkFile() ) ) {
404 // the way writing lnks doesn't really check for out 409 // the way writing lnks doesn't really check for out
405 // of disk space, but check it anyway. 410 // of disk space, but check it anyway.
406// if ( !lnk->writeLink() ) { 411// if ( !lnk->writeLink() ) {
407// QMessageBox::critical( 0, tr("Out of space"), 412// QMessageBox::critical( 0, tr("Out of space"),
408// tr( "There was a problem saving " 413// tr( "There was a problem saving "
409// "the playlist.\n" 414// "the playlist.\n"
410// "Your playlist " 415// "Your playlist "
411// "may be missing some entries\n" 416// "may be missing some entries\n"
412// "the next time you start it." ) 417// "the next time you start it." )
413// ); 418// );
414// } 419// }
415 420
416 } 421 }
417 noOfFiles++; 422 noOfFiles++;
418 } 423 }
419 } 424 }
420 while ( d->selectedFiles->next() ); 425 while ( d->selectedFiles->next() );
421 cfg.writeEntry("NumberOfFiles", noOfFiles ); 426 cfg.writeEntry("NumberOfFiles", noOfFiles );
422} 427}
423 428
424 429
425void PlayListWidget::addToSelection( const DocLnk& lnk ) { 430void PlayListWidget::addToSelection( const DocLnk& lnk ) {
426 d->setDocumentUsed = false; 431 d->setDocumentUsed = false;
427 if ( mediaPlayerState->playlist() ) { 432 if ( mediaPlayerState->playlist() ) {
428 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 433 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
429 d->selectedFiles->addToSelection( lnk ); 434 d->selectedFiles->addToSelection( lnk );
430 } 435 }
431 else 436 else
432 mediaPlayerState->setPlaying( true); 437 mediaPlayerState->setPlaying( true);
433 438
434} 439}
435 440
436 441
437void PlayListWidget::clearList() { 442void PlayListWidget::clearList() {
438 while ( first() ) 443 while ( first() )
439 d->selectedFiles->removeSelected(); 444 d->selectedFiles->removeSelected();
440 Config cfg( "OpiePlayer" ); 445 Config cfg( "OpiePlayer" );
441 cfg.setGroup("PlayList"); 446 cfg.setGroup("PlayList");
442 cfg.writeEntry("CurrentPlaylist",""); 447 cfg.writeEntry("CurrentPlaylist","");
443 currentPlayList=""; 448 currentPlayList="";
444 449
445} 450}
446 451
447 452
448void PlayListWidget::addAllToList() { 453void PlayListWidget::addAllToList() {
449 DocLnkSet filesAll; 454 DocLnkSet filesAll;
450 Global::findDocuments(&filesAll, "video/*;audio/*"); 455 Global::findDocuments(&filesAll, "video/*;audio/*");
451 QListIterator<DocLnk> Adit( filesAll.children() ); 456 QListIterator<DocLnk> Adit( filesAll.children() );
452 for ( ; Adit.current(); ++Adit ) 457 for ( ; Adit.current(); ++Adit )
453 if(QFileInfo(Adit.current()->file()).exists()) 458 if(QFileInfo(Adit.current()->file()).exists())
454 d->selectedFiles->addToSelection( **Adit ); 459 d->selectedFiles->addToSelection( **Adit );
455 tabWidget->setCurrentPage(0); 460 tabWidget->setCurrentPage(0);
456 461
457 writeCurrentM3u(); 462 writeCurrentM3u();
458 d->selectedFiles->first(); 463 d->selectedFiles->first();
459} 464}
460 465
461 466
462void PlayListWidget::addAllMusicToList() { 467void PlayListWidget::addAllMusicToList() {
463 QListIterator<DocLnk> dit( files.children() ); 468 QListIterator<DocLnk> dit( files.children() );
464 for ( ; dit.current(); ++dit ) 469 for ( ; dit.current(); ++dit )
465 if(QFileInfo(dit.current()->file()).exists()) 470 if(QFileInfo(dit.current()->file()).exists())
466 d->selectedFiles->addToSelection( **dit ); 471 d->selectedFiles->addToSelection( **dit );
467 tabWidget->setCurrentPage(0); 472 tabWidget->setCurrentPage(0);
468 473
469 writeCurrentM3u(); 474 writeCurrentM3u();
470 d->selectedFiles->first(); 475 d->selectedFiles->first();
471} 476}
472 477
473 478
474void PlayListWidget::addAllVideoToList() { 479void PlayListWidget::addAllVideoToList() {
475 QListIterator<DocLnk> dit( vFiles.children() ); 480 QListIterator<DocLnk> dit( vFiles.children() );
476 for ( ; dit.current(); ++dit ) 481 for ( ; dit.current(); ++dit )
477 if(QFileInfo( dit.current()->file()).exists()) 482 if(QFileInfo( dit.current()->file()).exists())
478 d->selectedFiles->addToSelection( **dit ); 483 d->selectedFiles->addToSelection( **dit );
479 tabWidget->setCurrentPage(0); 484 tabWidget->setCurrentPage(0);
480 485
481 writeCurrentM3u(); 486 writeCurrentM3u();
482 d->selectedFiles->first(); 487 d->selectedFiles->first();
483} 488}
484 489
485 490
486void PlayListWidget::setDocument(const QString& fileref) { 491void PlayListWidget::setDocument(const QString& fileref) {
487 fromSetDocument = true; 492 fromSetDocument = true;
488 d->setDocumentUsed = TRUE; 493 d->setDocumentUsed = TRUE;
489 setDocumentEx(fileref); 494 setDocumentEx(fileref);
490} 495}
491 496
492void PlayListWidget::setDocumentEx(const QString& fileref) { 497void PlayListWidget::setDocumentEx(const QString& fileref) {
493 odebug << "opieplayer receive "+fileref << oendl; 498 owarn << "opieplayer receive "+fileref << oendl;
494 clearList(); 499 clearList();
495 DocLnk lnk; 500 DocLnk lnk;
496 QFileInfo fileInfo(fileref); 501 QFileInfo fileInfo(fileref);
497 if ( !fileInfo.exists() ) { 502 if ( !fileInfo.exists() ) {
498 QMessageBox::critical( 0, tr( "Invalid File" ), 503 QMessageBox::critical( 0, tr( "Invalid File" ),
499 tr( "There was a problem in getting the file." ) ); 504 tr( "There was a problem in getting the file." ) );
500 return; 505 return;
501 } 506 }
502 // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl; 507 // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl;
503 QString extension = fileInfo.extension(false); 508 QString extension = fileInfo.extension(false);
504 if( extension.find( "m3u", 0, false) != -1) { //is m3u 509 if( extension.find( "m3u", 0, false) != -1) { //is m3u
505 readm3u( fileref); 510 readm3u( fileref);
506 } 511 }
507 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 512 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
508 readPls( fileref); 513 readPls( fileref);
509 } 514 }
510 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 515 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
511 clearList(); 516 clearList();
512 lnk.setName( fileInfo.baseName() ); //sets name 517 lnk.setName( fileInfo.baseName() ); //sets name
513 lnk.setFile( fileref ); //sets file name 518 lnk.setFile( fileref ); //sets file name
514 lnk.setIcon("Sound"); 519 lnk.setIcon("Sound");
515 //addToSelection( lnk ); 520 //addToSelection( lnk );
516 521
517 loadList( lnk); 522 loadList( lnk);
518 d->selectedFiles->first(); 523 d->selectedFiles->first();
519 } else { 524 } else {
520 if( fileref.find(".desktop",0,TRUE) != -1) { 525 if( fileref.find(".desktop",0,TRUE) != -1) {
521 lnk = DocLnk(fileref); 526 lnk = DocLnk(fileref);
522 } else { 527 } else {
523 lnk.setName( fileInfo.baseName() ); //sets name 528 lnk.setName( fileInfo.baseName() ); //sets name
524 lnk.setFile( fileref ); //sets file name 529 lnk.setFile( fileref ); //sets file name
525 lnk.setIcon("Sound"); 530 lnk.setIcon("Sound");
526 } 531 }
527 532
528 addToSelection( lnk ); 533 addToSelection( lnk );
529 // addToSelection( DocLnk( fileref ) ); 534 // addToSelection( DocLnk( fileref ) );
530 lnk.removeLinkFile(); 535 lnk.removeLinkFile();
531 // qApp->processEvents(); 536 // qApp->processEvents();
532 } 537 }
533 setCaption(tr("OpiePlayer")); 538 setCaption(tr("OpiePlayer"));
534 d->setDocumentUsed = TRUE; 539 d->setDocumentUsed = TRUE;
535 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); 540 d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
536 mediaPlayerState->setPlaying( FALSE ); 541 mediaPlayerState->setPlaying( FALSE );
537 qApp->processEvents(); 542 qApp->processEvents();
538 mediaPlayerState->setPlaying( TRUE ); 543 mediaPlayerState->setPlaying( TRUE );
539 544
540} 545}
541 546
542 547
543void PlayListWidget::setActiveWindow() { 548void PlayListWidget::setActiveWindow() {
544 // odebug << "SETTING active window" << oendl; 549 // odebug << "SETTING active window" << oendl;
545 // When we get raised we need to ensure that it switches views 550 // When we get raised we need to ensure that it switches views
546 char origView = mediaPlayerState->view(); 551 char origView = mediaPlayerState->view();
547 mediaPlayerState->setView( 'l' ); // invalidate 552 mediaPlayerState->setView( 'l' ); // invalidate
548 mediaPlayerState->setView( origView ); // now switch back 553 mediaPlayerState->setView( origView ); // now switch back
549} 554}
550 555
551 556
552void PlayListWidget::useSelectedDocument() { 557void PlayListWidget::useSelectedDocument() {
553 d->setDocumentUsed = FALSE; 558 d->setDocumentUsed = FALSE;
554} 559}
555 560
556 561
557const DocLnk *PlayListWidget::current() { // this is fugly 562const DocLnk *PlayListWidget::current() { // this is fugly
558 switch (tabWidget->currentPageIndex()) { 563 switch (tabWidget->currentPageIndex()) {
559 case 0: //playlist 564 case 0: //playlist
560 { 565 {
561 // odebug << "playlist" << oendl; 566 // odebug << "playlist" << oendl;
562 if ( mediaPlayerState->playlist() ) { 567 if ( mediaPlayerState->playlist() ) {
563 return d->selectedFiles->current(); 568 return d->selectedFiles->current();
564 } 569 }
565 else if ( d->setDocumentUsed && d->current ) { 570 else if ( d->setDocumentUsed && d->current ) {
566 return d->current; 571 return d->current;
567 } else { 572 } else {
568 return &(d->files->selectedDocument()); 573 return &(d->files->selectedDocument());
569 } 574 }
570 } 575 }
571 break; 576 break;
572 case 1://audio 577 case 1://audio
573 { 578 {
574 // odebug << "audioView" << oendl; 579 // odebug << "audioView" << oendl;
575 QListIterator<DocLnk> dit( files.children() ); 580 QListIterator<DocLnk> dit( files.children() );
576 for ( ; dit.current(); ++dit ) { 581 for ( ; dit.current(); ++dit ) {
577 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 582 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
578 insanityBool=TRUE; 583 insanityBool=TRUE;
579 return dit; 584 return dit;
580 } 585 }
581 } 586 }
582 } 587 }
583 break; 588 break;
584 case 2: // video 589 case 2: // video
585 { 590 {
586 QListIterator<DocLnk> Vdit( vFiles.children() ); 591 QListIterator<DocLnk> Vdit( vFiles.children() );
587 for ( ; Vdit.current(); ++Vdit ) { 592 for ( ; Vdit.current(); ++Vdit ) {
588 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 593 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
589 insanityBool=TRUE; 594 insanityBool=TRUE;
590 return Vdit; 595 return Vdit;
591 } 596 }
592 } 597 }
593 } 598 }
594 break; 599 break;
595 }; 600 };
596 return 0; 601 return 0;
597} 602}
598 603
599bool PlayListWidget::prev() { 604bool PlayListWidget::prev() {
600 if ( mediaPlayerState->playlist() ) { 605 if ( mediaPlayerState->playlist() ) {
601 if ( mediaPlayerState->shuffled() ) { 606 if ( mediaPlayerState->shuffled() ) {
602 const DocLnk *cur = current(); 607 const DocLnk *cur = current();
603 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 608 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
604 for ( int i = 0; i < j; i++ ) { 609 for ( int i = 0; i < j; i++ ) {
605 if ( !d->selectedFiles->next() ) 610 if ( !d->selectedFiles->next() )
606 d->selectedFiles->first(); 611 d->selectedFiles->first();
607 } 612 }
608 if ( cur == current() ) 613 if ( cur == current() )
609 if ( !d->selectedFiles->next() ) 614 if ( !d->selectedFiles->next() )
610 d->selectedFiles->first(); 615 d->selectedFiles->first();
611 return TRUE; 616 return TRUE;
612 } else { 617 } else {
613 if ( !d->selectedFiles->prev() ) { 618 if ( !d->selectedFiles->prev() ) {
614 if ( mediaPlayerState->looping() ) { 619 if ( mediaPlayerState->looping() ) {
615 return d->selectedFiles->last(); 620 return d->selectedFiles->last();
616 } else { 621 } else {
617 return FALSE; 622 return FALSE;
618 } 623 }
619 } 624 }
620 return TRUE; 625 return TRUE;
621 } 626 }
622 } else { 627 } else {
623 return mediaPlayerState->looping(); 628 return mediaPlayerState->looping();
624 } 629 }
625} 630}
626 631
627 632
628bool PlayListWidget::next() { 633bool PlayListWidget::next() {
629 if ( mediaPlayerState->playlist() ) { 634 if ( mediaPlayerState->playlist() ) {
630 if ( mediaPlayerState->shuffled() ) { 635 if ( mediaPlayerState->shuffled() ) {
631 return prev(); 636 return prev();
632 } else { 637 } else {
633 if ( !d->selectedFiles->next() ) { 638 if ( !d->selectedFiles->next() ) {
634 if ( mediaPlayerState->looping() ) { 639 if ( mediaPlayerState->looping() ) {
635 return d->selectedFiles->first(); 640 return d->selectedFiles->first();
636 } else { 641 } else {
637 return FALSE; 642 return FALSE;
638 } 643 }
639 } 644 }
640 return TRUE; 645 return TRUE;
641 } 646 }
642 } else { 647 } else {
643 return mediaPlayerState->looping(); 648 return mediaPlayerState->looping();
644 } 649 }
645} 650}
646 651
647 652
648bool PlayListWidget::first() { 653bool PlayListWidget::first() {
649 if ( mediaPlayerState->playlist() ) 654 if ( mediaPlayerState->playlist() )
650 return d->selectedFiles->first(); 655 return d->selectedFiles->first();
651 else 656 else
652 return mediaPlayerState->looping(); 657 return mediaPlayerState->looping();
653} 658}
654 659
655 660
656bool PlayListWidget::last() { 661bool PlayListWidget::last() {
657 if ( mediaPlayerState->playlist() ) 662 if ( mediaPlayerState->playlist() )
658 return d->selectedFiles->last(); 663 return d->selectedFiles->last();
659 else 664 else
660 return mediaPlayerState->looping(); 665 return mediaPlayerState->looping();
661} 666}
662 667
663 668
664void PlayListWidget::saveList() { 669void PlayListWidget::saveList() {
665 writem3u(); 670 writem3u();
666} 671}
667 672
668void PlayListWidget::loadList( const DocLnk & lnk) { 673void PlayListWidget::loadList( const DocLnk & lnk) {
669 QString name = lnk.name(); 674 QString name = lnk.name();
670 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; 675 // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl;
671 676
672 if( name.length()>0) { 677 if( name.length()>0) {
673 setCaption("OpiePlayer: "+name); 678 setCaption("OpiePlayer: "+name);
674 // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; 679 // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl;
675 clearList(); 680 clearList();
676 readm3u(lnk.file()); 681 readm3u(lnk.file());
677 tabWidget->setCurrentPage(0); 682 tabWidget->setCurrentPage(0);
678 } 683 }
679} 684}
680 685
681void PlayListWidget::setPlaylist( bool shown ) { 686void PlayListWidget::setPlaylist( bool shown ) {
682 if ( shown ) 687 if ( shown )
683 d->playListFrame->show(); 688 d->playListFrame->show();
684 else 689 else
685 d->playListFrame->hide(); 690 d->playListFrame->hide();
686} 691}
687 692
688void PlayListWidget::setView( char view ) { 693void PlayListWidget::setView( char view ) {
689 if ( view == 'l' ) 694 if ( view == 'l' )
690 QPEApplication::showWidget( this ); 695 QPEApplication::showWidget( this );
691 else 696 else
692 hide(); 697 hide();
693} 698}
694 699
695void PlayListWidget::addSelected() { 700void PlayListWidget::addSelected() {
696 DocLnk lnk; 701 DocLnk lnk;
697 QString filename; 702 QString filename;
698 switch (tabWidget->currentPageIndex()) { 703 switch (tabWidget->currentPageIndex()) {
699 704
700 case 0: //playlist 705 case 0: //playlist
701 return; 706 return;
702 break; 707 break;
703 case 1: { //audio 708 case 1: { //audio
704 QListViewItemIterator it( audioView ); 709 QListViewItemIterator it( audioView );
705 for ( ; it.current(); ++it ) { 710 for ( ; it.current(); ++it ) {
706 if ( it.current()->isSelected() ) { 711 if ( it.current()->isSelected() ) {
707 filename = it.current()->text(3); 712 filename = it.current()->text(3);
708 lnk.setName( QFileInfo(filename).baseName() ); //sets name 713 lnk.setName( QFileInfo(filename).baseName() ); //sets name
709 lnk.setFile( filename ); //sets file name 714 lnk.setFile( filename ); //sets file name
710 d->selectedFiles->addToSelection( lnk); 715 d->selectedFiles->addToSelection( lnk);
711 } 716 }
712 } 717 }
713 audioView->clearSelection(); 718 audioView->clearSelection();
714 // d->selectedFiles->next(); 719 // d->selectedFiles->next();
715 } 720 }
716 break; 721 break;
717 722
718 case 2: { // video 723 case 2: { // video
719 QListViewItemIterator it( videoView ); 724 QListViewItemIterator it( videoView );
720 for ( ; it.current(); ++it ) { 725 for ( ; it.current(); ++it ) {
721 if ( it.current()->isSelected() ) { 726 if ( it.current()->isSelected() ) {
722 727
723 filename = it.current()->text(3); 728 filename = it.current()->text(3);
724 lnk.setName( QFileInfo(filename).baseName() ); //sets name 729 lnk.setName( QFileInfo(filename).baseName() ); //sets name
725 lnk.setFile( filename ); //sets file name 730 lnk.setFile( filename ); //sets file name
726 d->selectedFiles->addToSelection( lnk); 731 d->selectedFiles->addToSelection( lnk);
727 } 732 }
728 } 733 }
729 videoView->clearSelection(); 734 videoView->clearSelection();
730 } 735 }
731 break; 736 break;
732 }; 737 };
733 // tabWidget->setCurrentPage(0); 738 // tabWidget->setCurrentPage(0);
734 writeCurrentM3u(); 739 writeCurrentM3u();
735 740
736} 741}
737 742
738void PlayListWidget::removeSelected() { 743void PlayListWidget::removeSelected() {
739 d->selectedFiles->removeSelected( ); 744 d->selectedFiles->removeSelected( );
740} 745}
741 746
742void PlayListWidget::playIt( QListViewItem *) { 747void PlayListWidget::playIt( QListViewItem *) {
743 // d->setDocumentUsed = FALSE; 748 // d->setDocumentUsed = FALSE;
744 // mediaPlayerState->curPosition =0; 749 // mediaPlayerState->curPosition =0;
745 // mediaPlayerState->setPlaying(FALSE); 750 // mediaPlayerState->setPlaying(FALSE);
746 mediaPlayerState->setPlaying(TRUE); 751 mediaPlayerState->setPlaying(TRUE);
747 d->selectedFiles->unSelect(); 752 d->selectedFiles->unSelect();
748} 753}
749 754
750void PlayListWidget::addToSelection( QListViewItem *it) { 755void PlayListWidget::addToSelection( QListViewItem *it) {
751 d->setDocumentUsed = FALSE; 756 d->setDocumentUsed = FALSE;
752 757
753 if(it) { 758 if(it) {
754 switch ( tabWidget->currentPageIndex()) { 759 switch ( tabWidget->currentPageIndex()) {
755 case 0: //playlist 760 case 0: //playlist
756 return; 761 return;
757 break; 762 break;
758 }; 763 };
759 // case 1: { 764 // case 1: {
760 DocLnk lnk; 765 DocLnk lnk;
761 QString filename; 766 QString filename;
762 767
763 filename=it->text(3); 768 filename=it->text(3);
764 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 769 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
765 lnk.setFile( filename ); //sets file name 770 lnk.setFile( filename ); //sets file name
766 d->selectedFiles->addToSelection( lnk); 771 d->selectedFiles->addToSelection( lnk);
767 772
768 if(tabWidget->currentPageIndex() == 0) 773 if(tabWidget->currentPageIndex() == 0)
769 writeCurrentM3u(); 774 writeCurrentM3u();
770 // tabWidget->setCurrentPage(0); 775 // tabWidget->setCurrentPage(0);
771 776
772 } 777 }
773} 778}
774 779
775void PlayListWidget::tabChanged(QWidget *) { 780void PlayListWidget::tabChanged(QWidget *) {
776 781
777 switch ( tabWidget->currentPageIndex()) { 782 switch ( tabWidget->currentPageIndex()) {
778 case 0: 783 case 0:
779 { 784 {
780 if( !tbDeletePlaylist->isHidden()) 785 if( !tbDeletePlaylist->isHidden())
781 tbDeletePlaylist->hide(); 786 tbDeletePlaylist->hide();
782 d->tbRemoveFromList->setEnabled(TRUE); 787 d->tbRemoveFromList->setEnabled(TRUE);
783 d->tbAddToList->setEnabled(FALSE); 788 d->tbAddToList->setEnabled(FALSE);
784 } 789 }
785 break; 790 break;
786 case 1: 791 case 1:
787 { 792 {
788 audioView->clear(); 793 audioView->clear();
789 populateAudioView(); 794 populateAudioView();
790 795
791 if( !tbDeletePlaylist->isHidden()) 796 if( !tbDeletePlaylist->isHidden())
792 tbDeletePlaylist->hide(); 797 tbDeletePlaylist->hide();
793 d->tbRemoveFromList->setEnabled(FALSE); 798 d->tbRemoveFromList->setEnabled(FALSE);
794 d->tbAddToList->setEnabled(TRUE); 799 d->tbAddToList->setEnabled(TRUE);
795 } 800 }
796 break; 801 break;
797 case 2: 802 case 2:
798 { 803 {
799 videoView->clear(); 804 videoView->clear();
800 populateVideoView(); 805 populateVideoView();
801 if( !tbDeletePlaylist->isHidden()) 806 if( !tbDeletePlaylist->isHidden())
802 tbDeletePlaylist->hide(); 807 tbDeletePlaylist->hide();
803 d->tbRemoveFromList->setEnabled(FALSE); 808 d->tbRemoveFromList->setEnabled(FALSE);
804 d->tbAddToList->setEnabled(TRUE); 809 d->tbAddToList->setEnabled(TRUE);
805 } 810 }
806 break; 811 break;
807 case 3: 812 case 3:
808 { 813 {
809 if( tbDeletePlaylist->isHidden()) 814 if( tbDeletePlaylist->isHidden())
810 tbDeletePlaylist->show(); 815 tbDeletePlaylist->show();
811 playLists->reread(); 816 playLists->reread();
812 } 817 }
813 break; 818 break;
814 }; 819 };
815} 820}
816 821
817void PlayListWidget::btnPlay(bool b) { 822void PlayListWidget::btnPlay(bool b) {
818 // mediaPlayerState->setPlaying(b); 823 // mediaPlayerState->setPlaying(b);
819 switch ( tabWidget->currentPageIndex()) { 824 switch ( tabWidget->currentPageIndex()) {
820 case 0: 825 case 0:
821 { 826 {
822 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 827 // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
823 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 828 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
824 // QMessageBox::message("Note","You are trying to play\na malformed url."); 829 // QMessageBox::message("Note","You are trying to play\na malformed url.");
825 // } else { 830 // } else {
826 mediaPlayerState->setPlaying(b); 831 mediaPlayerState->setPlaying(b);
827 insanityBool=FALSE; 832 insanityBool=FALSE;
828 odebug << "insanity" << oendl; 833 odebug << "insanity" << oendl;
829 // } 834 // }
830 } 835 }
831 break; 836 break;
832 case 1: 837 case 1:
833 { 838 {
834 // d->selectedFiles->unSelect(); 839 // d->selectedFiles->unSelect();
835 addToSelection( audioView->currentItem() ); 840 addToSelection( audioView->currentItem() );
836 mediaPlayerState->setPlaying( b); 841 mediaPlayerState->setPlaying( b);
837 d->selectedFiles->removeSelected( ); 842 d->selectedFiles->removeSelected( );
838 d->selectedFiles->unSelect(); 843 d->selectedFiles->unSelect();
839 tabWidget->setCurrentPage(1); 844 tabWidget->setCurrentPage(1);
840 insanityBool=FALSE; 845 insanityBool=FALSE;
841 }// audioView->clearSelection(); 846 }// audioView->clearSelection();
842 break; 847 break;
843 case 2: 848 case 2:
844 { 849 {
845 850
846 addToSelection( videoView->currentItem() ); 851 addToSelection( videoView->currentItem() );
847 mediaPlayerState->setPlaying( b); 852 mediaPlayerState->setPlaying( b);
848 // qApp->processEvents(); 853 // qApp->processEvents();
849 d->selectedFiles->removeSelected( ); 854 d->selectedFiles->removeSelected( );
850 d->selectedFiles->unSelect(); 855 d->selectedFiles->unSelect();
851 tabWidget->setCurrentPage(2); 856 tabWidget->setCurrentPage(2);
852 insanityBool=FALSE; 857 insanityBool=FALSE;
853 }// videoView->clearSelection(); 858 }// videoView->clearSelection();
854 break; 859 break;
855 }; 860 };
856 861
857} 862}
858 863
859void PlayListWidget::deletePlaylist() { 864void PlayListWidget::deletePlaylist() {
860 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 865 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
861 (tr("You really want to delete\nthis playlist?")), 866 (tr("You really want to delete\nthis playlist?")),
862 (tr("Yes")), (tr("No")), 0 )){ 867 (tr("Yes")), (tr("No")), 0 )){
863 case 0: // Yes clicked, 868 case 0: // Yes clicked,
864 QFile().remove(playLists->selectedDocument().file()); 869 QFile().remove(playLists->selectedDocument().file());
865 QFile().remove(playLists->selectedDocument().linkFile()); 870 QFile().remove(playLists->selectedDocument().linkFile());
866 playLists->reread(); 871 playLists->reread();
867 break; 872 break;
868 case 1: // Cancel 873 case 1: // Cancel
869 break; 874 break;
870 }; 875 };
871} 876}
872 877
873void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 878void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
874{ 879{
875 switch (mouse) { 880 switch (mouse) {
876 case 1: 881 case 1:
877 break; 882 break;
878 case 2:{ 883 case 2:{
879 884
880 QPopupMenu m; 885 QPopupMenu m;
881 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 886 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
882 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 887 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
883 m.insertSeparator(); 888 m.insertSeparator();
884 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 889 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
885 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 890 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
886 891
887 m.exec( QCursor::pos() ); 892 m.exec( QCursor::pos() );
888 } 893 }
889 break; 894 break;
890 }; 895 };
891} 896}
892 897
893void PlayListWidget::playSelected() 898void PlayListWidget::playSelected()
894{ 899{
895 btnPlay( true); 900 btnPlay( true);
896// d->selectedFiles->unSelect(); 901// d->selectedFiles->unSelect();
897} 902}
898 903
899void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 904void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
900{ 905{
901 switch (mouse) { 906 switch (mouse) {
902 case 1: 907 case 1:
903 908
904 break; 909 break;
905 case 2:{ 910 case 2:{
906 QPopupMenu m; 911 QPopupMenu m;
907 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 912 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
908 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 913 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
909 // m.insertSeparator(); 914 // m.insertSeparator();
910 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 915 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
911 m.exec( QCursor::pos() ); 916 m.exec( QCursor::pos() );
912 } 917 }
913 break; 918 break;
914 }; 919 };
915 920
916} 921}
917 922
918void PlayListWidget::listDelete() { 923void PlayListWidget::listDelete() {
919 Config cfg( "OpiePlayer" ); 924 Config cfg( "OpiePlayer" );
920 cfg.setGroup("PlayList"); 925 cfg.setGroup("PlayList");
921 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 926 currentPlayList = cfg.readEntry("CurrentPlaylist","");
922 QString file; 927 QString file;
923 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 928 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
924 switch ( tabWidget->currentPageIndex()) { 929 switch ( tabWidget->currentPageIndex()) {
925 case 0: 930 case 0:
926 break; 931 break;
927 case 1: 932 case 1:
928 { 933 {
929 file = audioView->currentItem()->text(0); 934 file = audioView->currentItem()->text(0);
930 QListIterator<DocLnk> Pdit( files.children() ); 935 QListIterator<DocLnk> Pdit( files.children() );
931 for ( ; Pdit.current(); ++Pdit ) { 936 for ( ; Pdit.current(); ++Pdit ) {
932 if( Pdit.current()->name() == file) { 937 if( Pdit.current()->name() == file) {
933 LnkProperties prop( Pdit.current() ); 938 LnkProperties prop( Pdit.current() );
934 QPEApplication::execDialog( &prop ); 939 QPEApplication::execDialog( &prop );
935 } 940 }
936 } 941 }
937 populateAudioView(); 942 populateAudioView();
938 } 943 }
939 break; 944 break;
940 case 2: 945 case 2:
941 { 946 {
942 // file = videoView->selectedItem()->text(0); 947 // file = videoView->selectedItem()->text(0);
943 // for ( int i = 0; i < noOfFiles; i++ ) { 948 // for ( int i = 0; i < noOfFiles; i++ ) {
944 // QString entryName; 949 // QString entryName;
945 // entryName.sprintf( "File%i", i + 1 ); 950 // entryName.sprintf( "File%i", i + 1 );
946 // QString linkFile = cfg.readEntry( entryName ); 951 // QString linkFile = cfg.readEntry( entryName );
947 // AppLnk lnk( AppLnk(linkFile)); 952 // AppLnk lnk( AppLnk(linkFile));
948 // if( lnk.name() == file ) { 953 // if( lnk.name() == file ) {
949 // LnkProperties prop( &lnk); 954 // LnkProperties prop( &lnk);
950 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); 955 // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*)));
951 // prop.showMaximized(); 956 // prop.showMaximized();
952 // prop.exec(); 957 // prop.exec();
953 // } 958 // }
954 // } 959 // }
955 } 960 }
956 break; 961 break;
957 }; 962 };
958} 963}
959 964
960void PlayListWidget::scanForAudio() { 965void PlayListWidget::scanForAudio() {
961 // odebug << "scan for audio" << oendl; 966 // odebug << "scan for audio" << oendl;
962 files.detachChildren(); 967 files.detachChildren();
963 QListIterator<DocLnk> sdit( files.children() ); 968 QListIterator<DocLnk> sdit( files.children() );
964 for ( ; sdit.current(); ++sdit ) { 969 for ( ; sdit.current(); ++sdit ) {
965 delete sdit.current(); 970 delete sdit.current();
966 } 971 }
967 Global::findDocuments( &files, audioMimes); 972 Global::findDocuments( &files, audioMimes);
968 audioScan = true; 973 audioScan = true;
969} 974}
970void PlayListWidget::scanForVideo() { 975void PlayListWidget::scanForVideo() {
971 // odebug << "scan for video" << oendl; 976 // odebug << "scan for video" << oendl;
972 vFiles.detachChildren(); 977 vFiles.detachChildren();
973 QListIterator<DocLnk> sdit( vFiles.children() ); 978 QListIterator<DocLnk> sdit( vFiles.children() );
974 for ( ; sdit.current(); ++sdit ) { 979 for ( ; sdit.current(); ++sdit ) {
975 delete sdit.current(); 980 delete sdit.current();
976 } 981 }
977 Global::findDocuments(&vFiles, "video/*"); 982 Global::findDocuments(&vFiles, "video/*");
978 videoScan = true; 983 videoScan = true;
979} 984}
980 985
981void PlayListWidget::populateAudioView() { 986void PlayListWidget::populateAudioView() {
982 987
983 audioView->clear(); 988 audioView->clear();
984 StorageInfo storageInfo; 989 StorageInfo storageInfo;
985 const QList<FileSystem> &fs = storageInfo.fileSystems(); 990 const QList<FileSystem> &fs = storageInfo.fileSystems();
986 if(!audioScan) scanForAudio(); 991 if(!audioScan) scanForAudio();
987 992
988 QListIterator<DocLnk> dit( files.children() ); 993 QListIterator<DocLnk> dit( files.children() );
989 QListIterator<FileSystem> it ( fs ); 994 QListIterator<FileSystem> it ( fs );
990 995
991 QString storage; 996 QString storage;
992 for ( ; dit.current(); ++dit ) { 997 for ( ; dit.current(); ++dit ) {
993 for( ; it.current(); ++it ){ 998 for( ; it.current(); ++it ){
994 const QString name = (*it)->name(); 999 const QString name = (*it)->name();
995 const QString path = (*it)->path(); 1000 const QString path = (*it)->path();
996 if(dit.current()->file().find(path) != -1 ) storage=name; 1001 if(dit.current()->file().find(path) != -1 ) storage=name;
997 } 1002 }
998 1003
999 QListViewItem * newItem; 1004 QListViewItem * newItem;
1000 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1005 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1001 long size; 1006 long size;
1002 if( dit.current()->file().left(4) == "http" ) 1007 if( dit.current()->file().left(4) == "http" )
1003 size=0; 1008 size=0;
1004 else 1009 else
1005 size = QFile( dit.current()->file() ).size(); 1010 size = QFile( dit.current()->file() ).size();
1006 // odebug << dit.current()->name() << oendl; 1011 // odebug << dit.current()->name() << oendl;
1007 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1012 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1008 QString::number(size ), storage, dit.current()->file()); 1013 QString::number(size ), storage, dit.current()->file());
1009 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/musicfile", Opie::Core::OResource::SmallIcon )); 1014 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/musicfile", Opie::Core::OResource::SmallIcon ));
1010 } 1015 }
1011 } 1016 }
1012 1017
1013} 1018}
1014 1019
1015void PlayListWidget::populateVideoView() { 1020void PlayListWidget::populateVideoView() {
1016 videoView->clear(); 1021 videoView->clear();
1017 StorageInfo storageInfo; 1022 StorageInfo storageInfo;
1018 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1023 const QList<FileSystem> &fs = storageInfo.fileSystems();
1019 1024
1020 if(!videoScan ) scanForVideo(); 1025 if(!videoScan ) scanForVideo();
1021 1026
1022 QListIterator<DocLnk> Vdit( vFiles.children() ); 1027 QListIterator<DocLnk> Vdit( vFiles.children() );
1023 QListIterator<FileSystem> it ( fs ); 1028 QListIterator<FileSystem> it ( fs );
1024 videoView->clear(); 1029 videoView->clear();
1025 QString storage; 1030 QString storage;
1026 for ( ; Vdit.current(); ++Vdit ) { 1031 for ( ; Vdit.current(); ++Vdit ) {
1027 for( ; it.current(); ++it ){ 1032 for( ; it.current(); ++it ){
1028 const QString name = (*it)->name(); 1033 const QString name = (*it)->name();
1029 const QString path = (*it)->path(); 1034 const QString path = (*it)->path();
1030 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1035 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1031 } 1036 }
1032 1037
1033 QListViewItem * newItem; 1038 QListViewItem * newItem;
1034 if ( QFile( Vdit.current()->file()).exists() ) { 1039 if ( QFile( Vdit.current()->file()).exists() ) {
1035 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1040 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1036 QString::number( QFile( Vdit.current()->file() ).size() ), 1041 QString::number( QFile( Vdit.current()->file() ).size() ),
1037 storage, Vdit.current()->file()); 1042 storage, Vdit.current()->file());
1038 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/videofile", Opie::Core::OResource::SmallIcon )); 1043 newItem->setPixmap(0, Opie::Core::OResource::loadPixmap( "opieplayer/videofile", Opie::Core::OResource::SmallIcon ));
1039 } 1044 }
1040 } 1045 }
1041} 1046}
1042 1047
1043void PlayListWidget::openFile() { 1048void PlayListWidget::openFile() {
1044 QString filename, name; 1049 QString filename, name;
1045 InputDialog *fileDlg; 1050 InputDialog *fileDlg;
1046 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1051 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1047 fileDlg->exec(); 1052 fileDlg->exec();
1048 if( fileDlg->result() == 1 ) { 1053 if( fileDlg->result() == 1 ) {
1049 filename = fileDlg->text(); 1054 filename = fileDlg->text();
1050 // odebug << "Selected filename is " + filename << oendl; 1055 // odebug << "Selected filename is " + filename << oendl;
1051 DocLnk lnk; 1056 DocLnk lnk;
1052 Config cfg( "OpiePlayer" ); 1057 Config cfg( "OpiePlayer" );
1053 cfg.setGroup("PlayList"); 1058 cfg.setGroup("PlayList");
1054 1059
1055 QString m3uFile; 1060 QString m3uFile;
1056 m3uFile = filename; 1061 m3uFile = filename;
1057 if(filename.left(4) == "http") { 1062 if(filename.left(4) == "http") {
1058 if(filename.find(":",8,TRUE) != -1) { //found a port 1063 if(filename.find(":",8,TRUE) != -1) { //found a port
1059 1064
1060 m3uFile = filename; 1065 m3uFile = filename;
1061 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1066 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1062 m3uFile += "/"; 1067 m3uFile += "/";
1063 } 1068 }
1064 filename = m3uFile; 1069 filename = m3uFile;
1065 } 1070 }
1066 lnk.setName( m3uFile ); //sets name 1071 if( filename.right(3) == "xml" ||
1067 lnk.setFile( filename ); //sets file name 1072 filename.find("rss" ) !=-1)
1068 lnk.setIcon("opieplayer2/musicfile"); 1073 {
1069 d->selectedFiles->addToSelection( lnk ); 1074 // readpodcast(filename );
1070 writeCurrentM3u(); 1075 downloadPodcast(filename);
1076 } else {
1077 lnk.setName( m3uFile ); //sets name
1078 lnk.setFile( filename ); //sets file name
1079 lnk.setIcon("opieplayer2/musicfile");
1080 d->selectedFiles->addToSelection( lnk );
1081 writeCurrentM3u();
1082 }
1071 } 1083 }
1072 else if( filename.right( 3) == "m3u" ) { 1084 else if( filename.right( 3) == "m3u" ) {
1073 readm3u( filename ); 1085 readm3u( filename );
1074 1086
1075 } else if( filename.right(3) == "pls" ) { 1087 } else if( filename.right(3) == "pls" ) {
1076 readPls( filename ); 1088 readPls( filename );
1089 } else if( filename.right(3) == "xml" ||
1090 filename.find("rss" ) !=-1
1091 ) {
1092 readpodcast( filename );
1077 } else { 1093 } else {
1078 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1094 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1079 lnk.setFile( filename ); //sets file name 1095 lnk.setFile( filename ); //sets file name
1080 d->selectedFiles->addToSelection( lnk); 1096 d->selectedFiles->addToSelection( lnk);
1081 lnk.removeLinkFile(); 1097 lnk.removeLinkFile();
1082 writeCurrentM3u(); 1098 writeCurrentM3u();
1083 } 1099 }
1084 } 1100 }
1085 1101
1086 if( fileDlg ) { 1102 if( fileDlg ) {
1087 delete fileDlg; 1103 delete fileDlg;
1088 } 1104 }
1089} 1105}
1090 1106
1091 1107
1092/* 1108/*
1093reads m3u and shows files/urls to playlist widget */
1094void PlayListWidget::readm3u( const QString &filename ) {
1095 // odebug << "read m3u filename " + filename << oendl;
1096
1097 Om3u *m3uList;
1098 QString s, name;
1099 m3uList = new Om3u( filename, IO_ReadOnly );
1100 m3uList->readM3u();
1101 DocLnk lnk;
1102 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1103 s = *it;
1104 // odebug << "reading "+ s << oendl;
1105 if(s.left(4)=="http") {
1106 lnk.setName( s ); //sets file name
1107 lnk.setIcon("opieplayer2/musicfile");
1108
1109 // if(s.right(4) != '.' || s.right(5) != '.')
1110 if(s.right(4) != '.' || s.right(5) != '.' )
1111 if( s.right(1) != "/")
1112 lnk.setFile( s+"/"); //if url with no extension
1113 else
1114 lnk.setFile( s ); //sets file name
1115
1116 } else {
1117 // if( QFileInfo( s ).exists() ) {
1118 lnk.setName( fullBaseName ( QFileInfo(s)));
1119 // if(s.right(4) == '.') {//if regular file
1120 if(s.left(1) != "/") {
1121 // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl;
1122 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1123 lnk.setIcon("SoundPlayer");
1124 } else {
1125 // odebug << "set link2 "+s << oendl;
1126 lnk.setFile( s);
1127 lnk.setIcon("SoundPlayer");
1128 }
1129 }
1130 d->selectedFiles->addToSelection( lnk );
1131 }
1132 Config config( "OpiePlayer" );
1133 config.setGroup( "PlayList" );
1134
1135 config.writeEntry("CurrentPlaylist",filename);
1136 config.write();
1137 currentPlayList=filename;
1138
1139// m3uList->write();
1140 m3uList->close();
1141 if(m3uList) delete m3uList;
1142
1143 d->selectedFiles->setSelectedItem( s);
1144 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1145
1146}
1147
1148/*
1149reads pls and adds files/urls to playlist */
1150void PlayListWidget::readPls( const QString &filename ) {
1151
1152 // odebug << "pls filename is " + filename << oendl;
1153 Om3u *m3uList;
1154 QString s, name;
1155 m3uList = new Om3u( filename, IO_ReadOnly );
1156 m3uList->readPls();
1157
1158 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1159 s = *it;
1160 // s.replace( QRegExp( "%20" )," " );
1161 DocLnk lnk( s );
1162 QFileInfo f( s );
1163 QString name = fullBaseName ( f);
1164
1165 if( name.left( 4 ) == "http" ) {
1166 name = s.right( s.length() - 7);
1167 } else {
1168 name = s;
1169 }
1170
1171 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1172
1173 lnk.setName( name );
1174 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1175 lnk.setFile( s );
1176 } else { //if its a url
1177 if( name.right( 1 ).find( '/' ) == -1) {
1178 s += "/";
1179 }
1180 lnk.setFile( s );
1181 }
1182 lnk.setType( "audio/x-mpegurl" );
1183
1184 lnk.writeLink();
1185 d->selectedFiles->addToSelection( lnk );
1186 }
1187
1188 m3uList->close();
1189 if(m3uList) delete m3uList;
1190}
1191
1192/*
1193 writes current playlist to current m3u file */ 1109 writes current playlist to current m3u file */
1194void PlayListWidget::writeCurrentM3u() { 1110void PlayListWidget::writeCurrentM3u() {
1195 // odebug << "writing to current m3u" << oendl; 1111 // odebug << "writing to current m3u" << oendl;
1196 Config cfg( "OpiePlayer" ); 1112 Config cfg( "OpiePlayer" );
1197 cfg.setGroup("PlayList"); 1113 cfg.setGroup("PlayList");
1198 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 1114 currentPlayList = cfg.readEntry("CurrentPlaylist","");
1199 Om3u *m3uList; 1115 Om3u *m3uList;
1200 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); 1116 m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
1201 1117
1202 if( d->selectedFiles->first()) { 1118 if( d->selectedFiles->first()) {
1203 do { 1119 do {
1204 // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 1120 // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
1205 m3uList->add( d->selectedFiles->current()->file() ); 1121 m3uList->add( d->selectedFiles->current()->file() );
1206 } 1122 }
1207 while ( d->selectedFiles->next() ); 1123 while ( d->selectedFiles->next() );
1208 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 1124 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
1209 m3uList->write(); 1125 m3uList->write();
1210 m3uList->close(); 1126 m3uList->close();
1211 1127
1212 if(m3uList) delete m3uList; 1128 if(m3uList) delete m3uList;
1213 } 1129 }
1214} 1130}
1215 1131
1216 /* 1132 /*
1217 writes current playlist to m3u file */ 1133 writes current playlist to m3u file */
1218void PlayListWidget::writem3u() { 1134void PlayListWidget::writem3u() {
1219 InputDialog *fileDlg; 1135 InputDialog *fileDlg;
1220 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1136 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1221 fileDlg->exec(); 1137 fileDlg->exec();
1222 QString name, filename, list; 1138 QString name, filename, list;
1223 Om3u *m3uList; 1139 Om3u *m3uList;
1224 1140
1225 if( fileDlg->result() == 1 ) { 1141 if( fileDlg->result() == 1 ) {
1226 name = fileDlg->text(); 1142 name = fileDlg->text();
1227 // odebug << filename << oendl; 1143 // odebug << filename << oendl;
1228 if( name.find("/",0,true) != -1) {// assume they specify a file path 1144 if( name.find("/",0,true) != -1) {// assume they specify a file path
1229 filename = name; 1145 filename = name;
1230 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1146 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1231 } 1147 }
1232 else //otherwise dump it somewhere noticable 1148 else //otherwise dump it somewhere noticable
1233 filename = QPEApplication::documentDir() + "/" + name; 1149 filename = QPEApplication::documentDir() + "/" + name;
1234 1150
1235 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1151 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1236 filename += ".m3u"; 1152 filename += ".m3u";
1237 1153
1238 if( d->selectedFiles->first()) { 1154 if( d->selectedFiles->first()) {
1239 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 1155 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
1240 1156
1241 do { 1157 do {
1242 m3uList->add( d->selectedFiles->current()->file()); 1158 m3uList->add( d->selectedFiles->current()->file());
1243 } 1159 }
1244 while ( d->selectedFiles->next() ); 1160 while ( d->selectedFiles->next() );
1245 // odebug << list << oendl; 1161 // odebug << list << oendl;
1246 m3uList->write(); 1162 m3uList->write();
1247 m3uList->close(); 1163 m3uList->close();
1248 if(m3uList) delete m3uList; 1164 if(m3uList) delete m3uList;
1249 1165
1250 if(fileDlg) delete fileDlg; 1166 if(fileDlg) delete fileDlg;
1251 1167
1252 DocLnk lnk; 1168 DocLnk lnk;
1253 lnk.setFile( filename); 1169 lnk.setFile( filename);
1254 lnk.setIcon("opieplayer2/playlist2"); 1170 lnk.setIcon("opieplayer2/playlist2");
1255 lnk.setName( name); //sets file name 1171 lnk.setName( name); //sets file name
1256 1172
1257 // odebug << filename << oendl; 1173 // odebug << filename << oendl;
1258 Config config( "OpiePlayer" ); 1174 Config config( "OpiePlayer" );
1259 config.setGroup( "PlayList" ); 1175 config.setGroup( "PlayList" );
1260 1176
1261 config.writeEntry("CurrentPlaylist",filename); 1177 config.writeEntry("CurrentPlaylist",filename);
1262 currentPlayList=filename; 1178 currentPlayList=filename;
1263 1179
1264 if(!lnk.writeLink()) { 1180 if(!lnk.writeLink()) {
1265 // odebug << "Writing doclink did not work" << oendl; 1181 // odebug << "Writing doclink did not work" << oendl;
1266 } 1182 }
1267 1183
1268 setCaption(tr("OpiePlayer: ") + name); 1184 setCaption(tr("OpiePlayer: ") + name);
1269 } 1185 }
1270 } 1186 }
1271} 1187}
1272 1188
1273 1189
1274void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1190void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1275{ 1191{
1276 switch ( e->key() ) { 1192 switch ( e->key() ) {
1277////////////////////////////// Zaurus keys 1193////////////////////////////// Zaurus keys
1278 case Key_F9: //activity 1194 case Key_F9: //activity
1279// if(audioUI->isHidden()) 1195// if(audioUI->isHidden())
1280// audioUI->showMaximized(); 1196// audioUI->showMaximized();
1281 break; 1197 break;
1282 case Key_F10: //contacts 1198 case Key_F10: //contacts
1283// if( videoUI->isHidden()) 1199// if( videoUI->isHidden())
1284// videoUI->showMaximized(); 1200// videoUI->showMaximized();
1285 break; 1201 break;
1286 case Key_F11: //menu 1202 case Key_F11: //menu
1287 break; 1203 break;
1288 case Key_F12: //home 1204 case Key_F12: //home
1289// doBlank(); 1205// doBlank();
1290 break; 1206 break;
1291 case Key_F13: //mail 1207 case Key_F13: //mail
1292// doUnblank(); 1208// doUnblank();
1293 break; 1209 break;
1294 case Key_Q: //add to playlist 1210 case Key_Q: //add to playlist
1295 addSelected(); 1211 addSelected();
1296 break; 1212 break;
1297 case Key_R: //remove from playlist 1213 case Key_R: //remove from playlist
1298 removeSelected(); 1214 removeSelected();
1299 break; 1215 break;
1300// case Key_P: //play 1216// case Key_P: //play
1301// odebug << "Play" << oendl; 1217// odebug << "Play" << oendl;
1302// playSelected(); 1218// playSelected();
1303// break; 1219// break;
1304 case Key_Space: 1220 case Key_Space:
1305// playSelected(); puh 1221// playSelected(); puh
1306 break; 1222 break;
1307 case Key_1: 1223 case Key_1:
1308 tabWidget->setCurrentPage(0); 1224 tabWidget->setCurrentPage(0);
1309 break; 1225 break;
1310 case Key_2: 1226 case Key_2:
1311 tabWidget->setCurrentPage(1); 1227 tabWidget->setCurrentPage(1);
1312 break; 1228 break;
1313 case Key_3: 1229 case Key_3:
1314 tabWidget->setCurrentPage(2); 1230 tabWidget->setCurrentPage(2);
1315 break; 1231 break;
1316 case Key_4: 1232 case Key_4:
1317 tabWidget->setCurrentPage(3); 1233 tabWidget->setCurrentPage(3);
1318 break; 1234 break;
1319 case Key_Down: 1235 case Key_Down:
1320 if ( !d->selectedFiles->next() ) 1236 if ( !d->selectedFiles->next() )
1321 d->selectedFiles->first(); 1237 d->selectedFiles->first();
1322 1238
1323 break; 1239 break;
1324 case Key_Up: 1240 case Key_Up:
1325 if ( !d->selectedFiles->prev() ) 1241 if ( !d->selectedFiles->prev() )
1326 // d->selectedFiles->last(); 1242 // d->selectedFiles->last();
1327 1243
1328 break; 1244 break;
1329 1245
1330 } 1246 }
1331} 1247}
1332 1248
1333void PlayListWidget::keyPressEvent( QKeyEvent *) 1249void PlayListWidget::keyPressEvent( QKeyEvent *)
1334{ 1250{
1335// odebug << "Key press" << oendl; 1251// odebug << "Key press" << oendl;
1336// switch ( e->key() ) { 1252// switch ( e->key() ) {
1337// ////////////////////////////// Zaurus keys 1253// ////////////////////////////// Zaurus keys
1338// case Key_A: //add to playlist 1254// case Key_A: //add to playlist
1339// odebug << "Add" << oendl; 1255// odebug << "Add" << oendl;
1340// addSelected(); 1256// addSelected();
1341// break; 1257// break;
1342// case Key_R: //remove from playlist 1258// case Key_R: //remove from playlist
1343// removeSelected(); 1259// removeSelected();
1344// break; 1260// break;
1345// case Key_P: //play 1261// case Key_P: //play
1346// odebug << "Play" << oendl; 1262// odebug << "Play" << oendl;
1347// playSelected(); 1263// playSelected();
1348// break; 1264// break;
1349// case Key_Space: 1265// case Key_Space:
1350// odebug << "Play" << oendl; 1266// odebug << "Play" << oendl;
1351// playSelected(); 1267// playSelected();
1352// break; 1268// break;
1353// } 1269// }
1354} 1270}
1355 1271
1356void PlayListWidget::doBlank() { 1272void PlayListWidget::doBlank() {
1357 // odebug << "do blanking" << oendl; 1273 // odebug << "do blanking" << oendl;
1358#ifdef QT_QWS_DEVFS 1274#ifdef QT_QWS_DEVFS
1359 fd=open("/dev/fb/0",O_RDWR); 1275 fd=open("/dev/fb/0",O_RDWR);
1360#else 1276#else
1361 fd=open("/dev/fb0",O_RDWR); 1277 fd=open("/dev/fb0",O_RDWR);
1362#endif 1278#endif
1363 if (fd != -1) { 1279 if (fd != -1) {
1364 ioctl(fd,FBIOBLANK,1); 1280 ioctl(fd,FBIOBLANK,1);
1365 // close(fd); 1281 // close(fd);
1366 } 1282 }
1367} 1283}
1368 1284
1369void PlayListWidget::doUnblank() { 1285void PlayListWidget::doUnblank() {
1370 // this crashes opieplayer with a segfault 1286 // this crashes opieplayer with a segfault
1371 // int fd; 1287 // int fd;
1372 // fd=open("/dev/fb0",O_RDWR); 1288 // fd=open("/dev/fb0",O_RDWR);
1373 // odebug << "do unblanking" << oendl; 1289 // odebug << "do unblanking" << oendl;
1374 if (fd != -1) { 1290 if (fd != -1) {
1375 ioctl(fd,FBIOBLANK,0); 1291 ioctl(fd,FBIOBLANK,0);
1376 close(fd); 1292 close(fd);
1377 } 1293 }
1378 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1294 QCopEnvelope h("QPE/System", "setBacklight(int)");
1379 h <<-3;// v[1]; // -3 Force on 1295 h <<-3;// v[1]; // -3 Force on
1380} 1296}
1381 1297
1382void PlayListWidget::populateSkinsMenu() { 1298void PlayListWidget::populateSkinsMenu() {
1383 int item = 0; 1299 int item = 0;
1384 defaultSkinIndex = 0; 1300 defaultSkinIndex = 0;
1385 QString skinName; 1301 QString skinName;
1386 Config cfg( "OpiePlayer" ); 1302 Config cfg( "OpiePlayer" );
1387 cfg.setGroup("Options" ); 1303 cfg.setGroup("Options" );
1388 QString skin = cfg.readEntry( "Skin", "default" ); 1304 QString skin = cfg.readEntry( "Skin", "default" );
1389 1305
1390 QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); 1306 QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" );
1391 skinsDir.setFilter( QDir::Dirs ); 1307 skinsDir.setFilter( QDir::Dirs );
1392 skinsDir.setSorting(QDir::Name ); 1308 skinsDir.setSorting(QDir::Name );
1393 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1309 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1394 QFileInfoListIterator it( *skinslist ); 1310 QFileInfoListIterator it( *skinslist );
1395 QFileInfo *fi; 1311 QFileInfo *fi;
1396 while ( ( fi = it.current() ) ) { 1312 while ( ( fi = it.current() ) ) {
1397 skinName = fi->fileName(); 1313 skinName = fi->fileName();
1398 // odebug << fi->fileName() << oendl; 1314 // odebug << fi->fileName() << oendl;
1399 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1315 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1400 item = skinsMenu->insertItem( fi->fileName() ) ; 1316 item = skinsMenu->insertItem( fi->fileName() ) ;
1401 } 1317 }
1402 if( skinName == "default" ) { 1318 if( skinName == "default" ) {
1403 defaultSkinIndex = item; 1319 defaultSkinIndex = item;
1404 } 1320 }
1405 if( skinName == skin ) { 1321 if( skinName == skin ) {
1406 skinsMenu->setItemChecked( item, TRUE ); 1322 skinsMenu->setItemChecked( item, TRUE );
1407 } 1323 }
1408 ++it; 1324 ++it;
1409 } 1325 }
1410} 1326}
1411 1327
1412void PlayListWidget::skinsMenuActivated( int item ) { 1328void PlayListWidget::skinsMenuActivated( int item ) {
1413 for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) { 1329 for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) {
1414 skinsMenu->setItemChecked( i, FALSE ); 1330 skinsMenu->setItemChecked( i, FALSE );
1415 } 1331 }
1416 skinsMenu->setItemChecked( item, TRUE ); 1332 skinsMenu->setItemChecked( item, TRUE );
1417 1333
1418 Config cfg( "OpiePlayer" ); 1334 Config cfg( "OpiePlayer" );
1419 cfg.setGroup("Options"); 1335 cfg.setGroup("Options");
1420 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1336 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1421} 1337}
1422 1338
1423void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1339void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1424 // odebug << "qcop message "+msg << oendl; 1340 // odebug << "qcop message "+msg << oendl;
1425 QDataStream stream ( data, IO_ReadOnly ); 1341 QDataStream stream ( data, IO_ReadOnly );
1426 if ( msg == "play()" ) { //plays current selection 1342 if ( msg == "play()" ) { //plays current selection
1427 btnPlay( true); 1343 btnPlay( true);
1428 } else if ( msg == "stop()" ) { 1344 } else if ( msg == "stop()" ) {
1429 mediaPlayerState->setPlaying( false); 1345 mediaPlayerState->setPlaying( false);
1430 } else if ( msg == "togglePause()" ) { 1346 } else if ( msg == "togglePause()" ) {
1431 mediaPlayerState->togglePaused(); 1347 mediaPlayerState->togglePaused();
1432 } else if ( msg == "next()" ) { //select next in lis 1348 } else if ( msg == "next()" ) { //select next in lis
1433 mediaPlayerState->setNext(); 1349 mediaPlayerState->setNext();
1434 } else if ( msg == "prev()" ) { //select previous in list 1350 } else if ( msg == "prev()" ) { //select previous in list
1435 mediaPlayerState->setPrev(); 1351 mediaPlayerState->setPrev();
1436 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1352 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1437 mediaPlayerState->toggleLooping(); 1353 mediaPlayerState->toggleLooping();
1438 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1354 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1439 mediaPlayerState->toggleShuffled(); 1355 mediaPlayerState->toggleShuffled();
1440 } else if ( msg == "volUp()" ) { //volume more 1356 } else if ( msg == "volUp()" ) { //volume more
1441 // emit moreClicked(); 1357 // emit moreClicked();
1442 // emit moreReleased(); 1358 // emit moreReleased();
1443 } else if ( msg == "volDown()" ) { //volume less 1359 } else if ( msg == "volDown()" ) { //volume less
1444 // emit lessClicked(); 1360 // emit lessClicked();
1445 // emit lessReleased(); 1361 // emit lessReleased();
1446 } else if ( msg == "play(QString)" ) { //play this now 1362 } else if ( msg == "play(QString)" ) { //play this now
1447 QString file; 1363 QString file;
1448 stream >> file; 1364 stream >> file;
1449 setDocumentEx( (const QString &) file); 1365 setDocumentEx( (const QString &) file);
1450 } else if ( msg == "add(QString)" ) { //add to playlist 1366 } else if ( msg == "add(QString)" ) { //add to playlist
1451 QString file; 1367 QString file;
1452 stream >> file; 1368 stream >> file;
1453 QFileInfo fileInfo(file); 1369 QFileInfo fileInfo(file);
1454 DocLnk lnk; 1370 DocLnk lnk;
1455 lnk.setName( fileInfo.baseName() ); //sets name 1371 lnk.setName( fileInfo.baseName() ); //sets name
1456 lnk.setFile( file ); //sets file name 1372 lnk.setFile( file ); //sets file name
1457 addToSelection( lnk ); 1373 addToSelection( lnk );
1458 } else if ( msg == "rem(QString)" ) { //remove from playlist 1374 } else if ( msg == "rem(QString)" ) { //remove from playlist
1459 QString file; 1375 QString file;
1460 stream >> file; 1376 stream >> file;
1461 } else if ( msg == "setDocument(QString)" ) { //loop or not loop 1377 } else if ( msg == "setDocument(QString)" ) { //loop or not loop
1462 QCopEnvelope h("QPE/Application/opieplayer", "raise()"); 1378 QCopEnvelope h("QPE/Application/opieplayer", "raise()");
1463 } 1379 }
1464} 1380}
1381
1382/*
1383reads m3u and shows files/urls to playlist widget */
1384void PlayListWidget::readm3u( const QString &filename ) {
1385 // odebug << "read m3u filename " + filename << oendl;
1386
1387 Om3u *m3uList;
1388 QString s, name;
1389 m3uList = new Om3u( filename, IO_ReadOnly );
1390 m3uList->readM3u();
1391 DocLnk lnk;
1392 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1393 s = *it;
1394 // odebug << "reading "+ s << oendl;
1395 if(s.left(4)=="http") {
1396 lnk.setName( s ); //sets file name
1397 lnk.setIcon("opieplayer2/musicfile");
1398
1399 // if(s.right(4) != '.' || s.right(5) != '.')
1400 if(s.right(4) != '.' || s.right(5) != '.' )
1401 if( s.right(1) != "/")
1402 lnk.setFile( s+"/"); //if url with no extension
1403 else
1404 lnk.setFile( s ); //sets file name
1405
1406 } else {
1407 // if( QFileInfo( s ).exists() ) {
1408 lnk.setName( fullBaseName ( QFileInfo(s)));
1409 // if(s.right(4) == '.') {//if regular file
1410 if(s.left(1) != "/") {
1411 // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl;
1412 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1413 lnk.setIcon("SoundPlayer");
1414 } else {
1415 // odebug << "set link2 "+s << oendl;
1416 lnk.setFile( s);
1417 lnk.setIcon("SoundPlayer");
1418 }
1419 }
1420 d->selectedFiles->addToSelection( lnk );
1421 }
1422 Config config( "OpiePlayer" );
1423 config.setGroup( "PlayList" );
1424
1425 config.writeEntry("CurrentPlaylist",filename);
1426 config.write();
1427 currentPlayList=filename;
1428
1429// m3uList->write();
1430 m3uList->close();
1431 if(m3uList) delete m3uList;
1432
1433 d->selectedFiles->setSelectedItem( s);
1434 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1435
1436}
1437
1438/*
1439reads pls and adds files/urls to playlist */
1440void PlayListWidget::readPls( const QString &filename )
1441{
1442 // odebug << "pls filename is " + filename << oendl;
1443 Om3u *m3uList;
1444 QString s, name;
1445 m3uList = new Om3u( filename, IO_ReadOnly );
1446 m3uList->readPls();
1447
1448 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1449 s = *it;
1450 // s.replace( QRegExp( "%20" )," " );
1451 DocLnk lnk( s );
1452 QFileInfo f( s );
1453 QString name = fullBaseName ( f);
1454
1455 if( name.left( 4 ) == "http" ) {
1456 name = s.right( s.length() - 7);
1457 } else {
1458 name = s;
1459 }
1460
1461 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1462
1463 lnk.setName( name );
1464 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1465 lnk.setFile( s );
1466 } else { //if its a url
1467 if( name.right( 1 ).find( '/' ) == -1) {
1468 s += "/";
1469 }
1470 lnk.setFile( s );
1471 }
1472 lnk.setType( "audio/x-mpegurl" );
1473
1474 lnk.writeLink();
1475 d->selectedFiles->addToSelection( lnk );
1476 }
1477
1478 m3uList->close();
1479 if(m3uList) delete m3uList;
1480}
1481
1482bool PlayListWidget::readpodcast( const QString &filename )
1483{
1484 QStringList latestPodCast;
1485 //download url
1486 qWarning("podcast "+filename);
1487 QFileInfo info(filename);
1488 if (info.size() > 0) {
1489 bool result = false;
1490 // qWarning("parseDoc " + feedFile.name() );
1491 QFile file(filename);
1492 QXmlInputSource source( file);
1493 QXmlSimpleReader reader;
1494 // reader.setFeature("http://xml.org/sax/features/namespaces", true);
1495 // reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
1496 // reader.setFeature("http://trolltech.com/xml/features/report-whitespace-only-CharData", false);
1497
1498 reader.setContentHandler( &rssHandler);
1499 reader.setErrorHandler( &rssHandler);
1500 result = reader.parse( source);
1501 if (!result) {
1502 QMessageBox::critical(0, "Error", tr("<p>Error unable to parse file.</p>"));
1503// qWarning("Error unable to parse file\n%s", handler.errorMessage.local8Bit().data());
1504 return false;
1505 } else {
1506 int size = rssHandler.getItems().size();
1507 qWarning( rssHandler.getChannelInfo().join("\n"));
1508
1509 for(int i = 0; i < size; i++) {
1510 QList<QStringList> attributesList = rssHandler.getItems().at(i)->attributes;
1511 QStringList *sList;
1512 QStringList attList;
1513 for(sList = attributesList.first(); sList !=0; sList = attributesList.next()) {
1514 for( QStringList::Iterator it = sList->begin(); it != sList->end(); ++it ) {
1515 attList << (*it);
1516 }
1517 if(i == 0) { //this assumes that the latest is the first
1518 latestPodCast << attList[2]; //this is our mp3 url
1519 latestPodCast << rssHandler.getItems().at(i)->title;
1520 latestPodCast << rssHandler.getItems().at(i)->description;
1521 latestPodCast << rssHandler.getItems().at(i)->pubdate;
1522 }
1523 }
1524 }
1525 QString s = latestPodCast[0]; //this is our mp3 url
1526
1527// http://www.davesipaq.com/podcast.xml
1528 DocLnk lnk( s );
1529 QFileInfo f( s );
1530 QString name = fullBaseName ( f);
1531
1532 if( name.left( 4 ) == "http" ) {
1533 name = s.right( s.length() - 7);
1534 } else {
1535 name = s;
1536 }
1537
1538 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1539
1540 lnk.setName( name );
1541 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1542 lnk.setFile( s );
1543 } else { //if its a url
1544 if( name.right( 1 ).find( '/' ) == -1) {
1545 s += "/";
1546 }
1547 lnk.setFile( s );
1548 }
1549 lnk.setType( "audio/x-mpegurl" );
1550
1551 lnk.writeLink();
1552 d->selectedFiles->addToSelection( lnk );
1553
1554 }
1555 } else {
1556 QMessageBox::critical( 0, "Qtopia Rss", tr("<p>Sorry, could not find the requested document.</p>"));
1557 return false;
1558 }
1559
1560 qWarning( latestPodCast.join("\n"));
1561
1562 return true;
1563}
1564
1565bool PlayListWidget::downloadPodcast(const QString &url)
1566{
1567 qWarning("download "+url);
1568 QString localFile;
1569 localFile = url;
1570 localFile = localFile.mid(7, localFile.length()-7);
1571
1572 localFile = localFile.replace(QRegExp("/"), "_");
1573 localFile = localFile.replace(QRegExp("&"), "_");
1574 localFile = localFile.replace(QRegExp("="), "_");
1575 localFile = localFile.replace(QRegExp("\\?"), "_");
1576 localFile = localFile.replace(QRegExp("@"), "_");
1577 localFile = QDir::homeDirPath()+"/Settings/"+localFile;
1578
1579#warning FIXME
1580 QString cmd;
1581 cmd = "wget ";
1582 cmd +=" -O ";
1583 cmd += localFile + " " + url;
1584 qWarning(cmd);
1585 system(cmd.latin1());
1586// Process ipkg_status(QStringList()<< "wget" <<"-O" << localFile << url );
1587 // QString out;
1588// bool r = ipkg_status.exec("",out);
1589// if(r)
1590// qWarning(out);
1591 readpodcast(localFile);
1592 return true;
1593}
1594
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 0c0e367..6e9acc0 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,138 +1,142 @@
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#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
30 30
31#include "om3u.h" 31#include "om3u.h"
32#include "rssparser.h"
32/* #include <qtimer.h> */ 33/* #include <qtimer.h> */
33 34
34 35
35class PlayListWidgetPrivate; 36class PlayListWidgetPrivate;
36class Config; 37class Config;
37class QListViewItem; 38class QListViewItem;
38class QListView; 39class QListView;
39class QPoint; 40class QPoint;
40class QAction; 41class QAction;
41class QLabel; 42class QLabel;
42class QPopupMenu; 43class QPopupMenu;
43 44
44class PlayListWidget : public QMainWindow { 45class PlayListWidget : public QMainWindow {
45 Q_OBJECT 46 Q_OBJECT
46public: 47public:
47 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 48 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
48 ~PlayListWidget(); 49 ~PlayListWidget();
49 QTabWidget * tabWidget; 50 QTabWidget * tabWidget;
50 QAction *fullScreenButton, *scaleButton; 51 QAction *fullScreenButton, *scaleButton;
51 DocLnkSet files; 52 DocLnkSet files;
52 DocLnkSet vFiles; 53 DocLnkSet vFiles;
53 QListView *audioView, *videoView, *playlistView; 54 QListView *audioView, *videoView, *playlistView;
54 QLabel *libString; 55 QLabel *libString;
55 bool fromSetDocument; 56 bool fromSetDocument;
56 bool insanityBool; 57 bool insanityBool;
57 QString setDocFileRef, currentPlayList; 58 QString setDocFileRef, currentPlayList;
58 // retrieve the current playlist entry (media file link) 59 // retrieve the current playlist entry (media file link)
59 const DocLnk *current(); 60 const DocLnk *current();
60 void useSelectedDocument(); 61 void useSelectedDocument();
61/* QTimer * menuTimer; */ 62/* QTimer * menuTimer; */
62 FileSelector* playLists; 63 FileSelector* playLists;
63 QPushButton *tbDeletePlaylist; 64 QPushButton *tbDeletePlaylist;
64 int fd, selected; 65 int fd, selected;
65public slots: 66public slots:
66 bool first(); 67 bool first();
67 bool last(); 68 bool last();
68 bool next(); 69 bool next();
69 bool prev(); 70 bool prev();
70/* void setFullScreen(); */ 71/* void setFullScreen(); */
71/* void setScaled(); */ 72/* void setScaled(); */
72protected: 73protected:
73 QCopChannel * channel; 74 QCopChannel * channel;
74 QPopupMenu *skinsMenu; 75 QPopupMenu *skinsMenu;
75/* void contentsMousePressEvent( QMouseEvent * e ); */ 76/* void contentsMousePressEvent( QMouseEvent * e ); */
76/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 77/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
77void keyReleaseEvent( QKeyEvent *e); 78 void keyReleaseEvent( QKeyEvent *e);
78void keyPressEvent( QKeyEvent *e); 79 void keyPressEvent( QKeyEvent *e);
79private: 80private:
81 RssParser rssHandler;
80 int defaultSkinIndex; 82 int defaultSkinIndex;
81 bool audioScan, videoScan; 83 bool audioScan, videoScan;
82 void doBlank(); 84 void doBlank();
83 void doUnblank(); 85 void doUnblank();
84 void readm3u(const QString &); 86 void readm3u(const QString &);
85 void readPls(const QString &); 87 void readPls(const QString &);
86 88 bool readpodcast(const QString&);
87 89
88 void initializeStates(); 90 void initializeStates();
89 void readConfig( Config& cfg ); 91 void readConfig( Config& cfg );
90 void writeConfig( Config& cfg ) const; 92 void writeConfig( Config& cfg ) const;
91 PlayListWidgetPrivate *d; // Private implementation data 93 PlayListWidgetPrivate *d; // Private implementation data
92 void populateAudioView(); 94 void populateAudioView();
93 void populateVideoView(); 95 void populateVideoView();
94private slots: 96private slots:
95 97
96 void qcopReceive(const QCString&, const QByteArray&); 98 void qcopReceive(const QCString&, const QByteArray&);
97 void populateSkinsMenu(); 99 void populateSkinsMenu();
98 void skinsMenuActivated(int); 100 void skinsMenuActivated(int);
99 void writem3u(); 101 void writem3u();
100 void writeCurrentM3u(); 102 void writeCurrentM3u();
101 void scanForAudio(); 103 void scanForAudio();
102 void scanForVideo(); 104 void scanForVideo();
103 void openFile(); 105 void openFile();
104 void setDocument( const QString& fileref ); 106 void setDocument( const QString& fileref );
105 void setDocumentEx( const QString& fileref ); 107 void setDocumentEx( const QString& fileref );
106 void addToSelection( const DocLnk& ); // Add a media file to the playlist 108 void addToSelection( const DocLnk& ); // Add a media file to the playlist
107 void addToSelection( QListViewItem* ); // Add a media file to the playlist 109 void addToSelection( QListViewItem* ); // Add a media file to the playlist
108 void setActiveWindow(); // need to handle this to show the right view 110 void setActiveWindow(); // need to handle this to show the right view
109 void setPlaylist( bool ); // Show/Hide the playlist 111 void setPlaylist( bool ); // Show/Hide the playlist
110 void setView( char ); 112 void setView( char );
111 void clearList(); 113 void clearList();
112 void addAllToList(); 114 void addAllToList();
113 void addAllMusicToList(); 115 void addAllMusicToList();
114 void addAllVideoToList(); 116 void addAllVideoToList();
115 void saveList(); // Save the playlist 117 void saveList(); // Save the playlist
116 void loadList( const DocLnk &); // Load a playlist 118 void loadList( const DocLnk &); // Load a playlist
117 void playIt( QListViewItem *); 119 void playIt( QListViewItem *);
118 120
119 void btnPlay(bool); 121 void btnPlay(bool);
120 void deletePlaylist(); 122 void deletePlaylist();
121 void addSelected(); 123 void addSelected();
122 void removeSelected(); 124 void removeSelected();
123 void tabChanged(QWidget*); 125 void tabChanged(QWidget*);
124 void viewPressed( int, QListViewItem *, const QPoint&, int); 126 void viewPressed( int, QListViewItem *, const QPoint&, int);
125 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 127 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
126 void playSelected(); 128 void playSelected();
127 void listDelete(); 129 void listDelete();
130
131 bool downloadPodcast(const QString &);
128 132
129protected slots: 133protected slots:
130/* void cancelMenuTimer(); */ 134/* void cancelMenuTimer(); */
131/* void showFileMenu(); */ 135/* void showFileMenu(); */
132 136
133 137
134}; 138};
135 139
136 140
137#endif // PLAY_LIST_WIDGET_H 141#endif // PLAY_LIST_WIDGET_H
138 142
diff --git a/core/multimedia/opieplayer/rssparser.cpp b/core/multimedia/opieplayer/rssparser.cpp
new file mode 100644
index 0000000..ec81409
--- a/dev/null
+++ b/core/multimedia/opieplayer/rssparser.cpp
@@ -0,0 +1,201 @@
1/***************************************************************************
2 * Copyright (C) 2004 by ljp *
3 * lpotter@trolltech.com *
4 * *
5 * This program may be distributed under the terms of the Q Public *
6 * License as defined by Trolltech AS of Norway and appearing in the *
7 * file LICENSE.QPL included in the packaging of this file. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12 ***************************************************************************/
13#include "rssparser.h"
14
15#include <qstring.h>
16#include <qmessagebox.h>
17#include <qlist.h>
18
19RssParser::RssParser()
20{
21 isItem = false;
22}
23
24RssParser::~RssParser()
25{
26 int size = channel->rssItems.size();
27 for (int i = 0; i < size; i ++) {
28 delete channel->rssItems.at(i);
29 }
30 delete channel;
31}
32
33bool RssParser::startElement( const QString &, const QString & /*localName*/,const QString & qName, const QXmlAttributes &atts)
34{
35 if( qName == "rss") {
36 channel = new rssChannel();
37 channel->rssItems.resize( 0);
38 return true;
39 }
40// qWarning(qName + " %d",atts.length());
41 if(qName == "item") {
42 isItem = true;
43 tag = NewItemTag;
44 Item = new rssItem();
45 }
46
47 if(qName == "image") {
48 tag = NewItemTag;
49 image = new rssImage();
50 }
51
52 if(qName == "title") {
53 tag = TitleTag;
54 }
55
56 if (qName == "description") {
57 tag = DescriptionTag;
58 }
59
60 if( qName == "link") {
61 tag = LinkTag;
62 }
63
64 if( qName == "pubDate") {
65 tag = pubDateTag;
66 }
67
68// if( qName == "enclosure") {
69// tag = EnclosureTag;
70// }
71
72 if(atts.length() > 0/* && tag == EnclosureTag*/) {
73// qWarning(qName +" attributes %d", atts.length());
74// Item->attributes << qName;
75// for(int i=0; i < atts.length(); i++) {
76// Item->attributes << atts.qName(i) << atts.value(atts.qName(i));
77// }
78
79 QStringList *sList;
80 sList = new QStringList();
81 sList->append(qName);
82 for(int i=0; i < atts.length(); i++) {
83 sList->append( atts.qName(i));
84 sList->append( atts.value(atts.qName(i)));
85 }
86 if(isItem)
87 Item->attributes.append( sList);
88 else
89 channel->attributes.append( sList);
90 }
91
92 return true;
93}
94
95bool RssParser::endElement( const QString &, const QString &, const QString & qName )
96{
97 tag = NoneTag;
98 if(qName == "item") {
99 isItem = false;
100 int size = channel->rssItems.size();
101 channel->rssItems.resize( size + 1);
102 channel->rssItems.insert( channel->rssItems.size() - 1, Item);
103 }
104 if(qName == "channel") {
105// isItem = false;
106// int size = channel->rssItems.size();
107// channel->rssItems.resize( size + 1);
108// channel->rssItems.insert( channel->rssItems.size() - 1, Item);
109 }
110 return true;
111}
112
113bool RssParser::characters( const QString & ch )
114{
115 if(!ch.isEmpty()) {
116 if(isItem) {
117// qWarning("ch "+ch);
118 switch(tag) {
119 case NewItemTag:
120 break;
121 case TitleTag:
122 Item->title = ch;
123 break;
124 case DescriptionTag:
125 Item->description = ch;
126 break;
127 case LinkTag:
128 Item->link = ch;
129 break;
130 case pubDateTag:
131 Item->pubdate = ch;
132 break;
133 case NoneTag:
134 break;
135 };
136 } else { //channel
137 switch(tag) {
138 case TitleTag:
139 channel->title = ch;
140 break;
141 case DescriptionTag:
142 channel->description = ch;
143 break;
144 case LinkTag:
145 channel->link = ch;
146 break;
147 case pubDateTag:
148 channel->pubdate = ch;
149 break;
150 case NoneTag:
151 case NewItemTag:
152 break;
153 };
154 }
155 }
156 return true;
157}
158
159bool RssParser::warning(const QXmlParseException &e)
160{
161 errorMessage = e.message();
162// QMessageBox::message("Warning",tr("<p>Sorry, could not find the requested document.</p>"));
163 qWarning("Warning " + errorMessage);
164 return true;
165}
166
167bool RssParser::error(const QXmlParseException &e)
168{
169 errorMessage = e.message();
170// QMessageBox::message("Error", "<p>" + errorMessage + "</p>");
171 qWarning("Error: " + errorMessage);
172 return true;
173}
174
175bool RssParser::fatalError(const QXmlParseException &e)
176{
177 errorMessage = e.message();
178// errorMessage += " line: " + e.lineNumber();
179// errorMessage += " col: " + e.columnNumber();
180 qWarning("Fatal Error: "+ errorMessage);
181 qWarning("line %d, col %d\n", e.lineNumber(), e.columnNumber());
182// QMessageBox::message("Fatal Error", errorMessage );
183 return false;
184}
185
186QVector<rssItem> &RssParser::getItems()
187{
188 return channel->rssItems;
189}
190
191int RssParser::getSize()
192{
193 return channel->rssItems.size();
194}
195
196QStringList RssParser::getChannelInfo()
197{
198 QStringList ch;
199 ch << channel->title << channel->description << channel->link << channel->pubdate << channel->copyright << channel->language;
200 return ch;
201}
diff --git a/core/multimedia/opieplayer/rssparser.h b/core/multimedia/opieplayer/rssparser.h
new file mode 100644
index 0000000..669ece5
--- a/dev/null
+++ b/core/multimedia/opieplayer/rssparser.h
@@ -0,0 +1,122 @@
1/***************************************************************************
2 * Copyright (C) 2004 by ljp *
3 * lpotter@trolltech.com *
4 * *
5 * This program may be distributed under the terms of the Q Public *
6 * License as defined by Trolltech AS of Norway and appearing in the *
7 * file LICENSE.QPL included in the packaging of this file. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12 ***************************************************************************/
13
14/* RSS required tags:
15 title,link,description
16*/
17/* RSS optional tags:
18 language,copyright,managingEditor,webMaster,pubDate,lastBuildDate,category,generator,docs,cloud,ttl,
19 image,rating,textInput,skipHours,skipDays
20*/
21/*
22 podcast tags
23 <rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
24 title,link,copyright,pubDate,enclosure,guid,itunes:author,itunes:block,itunes:category,itunes:duration,itunes:explicit,itunes:keywords,itunes:owner,itunes:subtitle,itunes:summary
25*/
26
27#ifndef RSSPARSER_H
28#define RSSPARSER_H
29
30#include <qxml.h>
31#include <qstringlist.h>
32#include <qvector.h>
33#include <qstringlist.h>
34#include <qlist.h>
35
36class QString;
37
38class rssImage {
39public:
40 QString url;
41 QString title;
42 int width;
43 int height;
44 QString description;
45};
46
47class rssItem {
48 public:
49 QString title;
50 QString description;
51 QString link;
52 QString pubdate;
53 QVector <rssImage> rssImageTags;
54 QList<QStringList> attributes; //tags with atttributes
55};
56
57class rssChannel {
58 public:
59 QString title;
60 QString description;
61 QString link;
62 QString pubdate;
63 QString copyright;
64 QString language;
65 QVector <rssImage> rssImageTags;
66 QVector <rssItem> rssItems;
67 QList<QStringList> attributes; //tags with atttributes
68};
69
70class RssParser : public QXmlDefaultHandler
71{
72public:
73 RssParser();
74 ~RssParser();
75 QString errorMessage;
76
77 QVector<rssItem> &getItems();
78 QStringList getChannelInfo();
79 int getSize();
80
81private:
82
83 enum Tag {
84 NoneTag = 0,
85 TitleTag = 1,
86 NewItemTag = 2,
87 DescriptionTag = 3,
88 LinkTag = 4,
89 pubDateTag = 5,
90/*
91 ImageTag = 6,
92 UrlTag = 7,
93 WidthTag = 8,
94 HeightTag = 9,
95 */
96 };
97 Tag tag;
98
99// QVector <rssItem> rssItems;
100 QStringList channelInfo;
101 rssItem *Item;
102 rssChannel *channel;
103 rssImage *image;
104
105 bool isItem;
106 QStringList tokenNames;
107 QString htmlString;
108
109protected:
110
111 bool startElement( const QString&, const QString&, const QString& ,const QXmlAttributes& );
112 bool endElement( const QString&, const QString&, const QString& );
113 bool characters( const QString &);
114
115 bool warning(const QXmlParseException &);
116 bool error(const QXmlParseException &);
117 bool fatalError(const QXmlParseException &);
118
119 QString itemTitle, itemLink, itemDescription;
120};
121
122#endif