summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-19 12:34:09 (UTC)
committer llornkcor <llornkcor>2002-06-19 12:34:09 (UTC)
commitb55f69a46fd27ce26235029f702c0f3942fde68c (patch) (side-by-side diff)
tree47aa9ca1e9c80367050a93715f384eef2285e7b9
parent1d60bfb5925c5009122ae04009f8e99658436b35 (diff)
downloadopie-b55f69a46fd27ce26235029f702c0f3942fde68c.zip
opie-b55f69a46fd27ce26235029f702c0f3942fde68c.tar.gz
opie-b55f69a46fd27ce26235029f702c0f3942fde68c.tar.bz2
dont crash on malformed urls
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 41fcb30..2323ac2 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -395,56 +395,62 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
// next time...
if ( !QFile::exists( lnk->linkFile() ) ) {
// the way writing lnks doesn't really check for out
// of disk space, but check it anyway.
if ( !lnk->writeLink() ) {
QMessageBox::critical( 0, tr("Out of space"),
tr( "There was a problem saving "
"the playlist.\n"
"Your playlist "
"may be missing some entries\n"
"the next time you start it." )
);
}
}
noOfFiles++;
}
}
while ( d->selectedFiles->next() );
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
// qDebug("add");
+ if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","You are trying to play\na malformed url.");
+
+ } else {
+
d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() ) {
if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
}
else
mediaPlayerState->setPlaying( TRUE );
}
+}
void PlayListWidget::clearList() {
while ( first() )
d->selectedFiles->removeSelected();
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;audio/*");
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit )
if(QFileInfo(Adit.current()->file()).exists())
d->selectedFiles->addToSelection( **Adit );
}
void PlayListWidget::addAllMusicToList() {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
if(QFileInfo(dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
}
@@ -825,76 +831,80 @@ void PlayListWidget::tabChanged(QWidget *widg) {
videoView->clear();
populateVideoView();
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 3:
{
if( tbDeletePlaylist->isHidden())
tbDeletePlaylist->show();
playLists->reread();
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
+ qDebug("here we are");
+ if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","You are trying to play\na malformed url.");
+
+ } else {
mediaPlayerState->setPlaying(b);
- }
+ } }
break;
case 1:
{
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(1);
d->selectedFiles->unSelect();
insanityBool=FALSE;
-// audioView->clearSelection();
- }
+ }// audioView->clearSelection();
break;
case 2:
{
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(2);
d->selectedFiles->unSelect();
insanityBool=FALSE;
-// videoView->clearSelection();
- }
+ }// videoView->clearSelection();
break;
};
+
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
case 0: // Yes clicked,
QFile().remove(playLists->selected()->file());
QFile().remove(playLists->selected()->linkFile());
playLists->reread();
break;
case 1: // Cancel
break;
};
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
@@ -1047,74 +1057,78 @@ void PlayListWidget::populateVideoView() {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if( Vdit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file()).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
QString::number( QFile( Vdit.current()->file()).size() ), storage);
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->LineEdit1->text();
// http://205.188.234.129:8030
// http://66.28.68.70:8000
- filename.replace(QRegExp("%20")," ");
-
+// filename.replace(QRegExp("%20")," ");
+ if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","Spaces in urls are not allowed.");
+ return;
+ } else {
qDebug("Selected filename is "+filename);
if(filename.right(3) == "m3u")
readm3u( filename);
else if(filename.right(3) == "pls")
readPls( filename);
else {
DocLnk lnk;
lnk.setName(filename); //sets file name
if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
filename += "/";
lnk.setFile(filename); //sets File property
lnk.setType("audio/x-mpegurl");
lnk.setExec("opieplayer");
lnk.setIcon("opieplayer/MPEGPlayer");
if(!lnk.writeLink())
qDebug("Writing doclink did not work");
d->selectedFiles->addToSelection( lnk);
// if(fileDlg2)
// delete fileDlg2;
}
}
+ }
if(fileDlg)
delete fileDlg;
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
{
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();
break;
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu
break;
case Key_F12: //home
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
@@ -1184,81 +1198,86 @@ void PlayListWidget::doUnblank() {
// this crashes opieplayer with a segfault
// int fd;
// fd=open("/dev/fb0",O_RDWR);
qDebug("do unblanking");
if (fd != -1) {
ioctl(fd,FBIOBLANK,0);
close(fd);
}
QCopEnvelope h("QPE/System", "setBacklight(int)");
h <<-3;// v[1]; // -3 Force on
}
void PlayListWidget::readm3u(const QString &filename) {
qDebug("m3u filename is "+filename);
QFile f(filename);
if(f.open(IO_ReadOnly)) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd()) {
// Lview->insertLine(t.readLine(),-1);
s=t.readLine();
- if(s.find("#",0,TRUE) == -1) {
+ if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","Spaces in urls are not allowed.");
+ }
+ else if(s.find("#",0,TRUE) == -1) {
if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
if(s.left(2) == "E:" || s.left(2) == "P:") {
s=s.right(s.length()-2);
DocLnk lnk( s );
QFileInfo f(s);
QString name = f.baseName();
name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
lnk.setName( name);
s=s.replace( QRegExp("\\"),"/");
lnk.setFile( s);
// lnk.setIcon(opieplayer/MPEGPlayer);
qDebug("add "+name);
d->selectedFiles->addToSelection( lnk);
} else { // is url
+
s.replace(QRegExp("%20")," ");
DocLnk lnk( s);
QString name = s.right( s.length() - 7);
// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
lnk.setName(name);
lnk.setFile( s+"/");
// lnk.setFile( filename);
// lnk.setComment( s+"/");
lnk.setType("audio/x-mpegurl");
// lnk.setIcon( "opieplayer/MPEGPlayer");
// qDebug("add "+s);
d->selectedFiles->addToSelection( lnk);
}
i++;
}
}
}
}
+ f.close();
}
void PlayListWidget::writem3u(const QString &filename) {
}
void PlayListWidget::readPls(const QString &filename) {
qDebug("pls filename is "+filename);
QFile f(filename);
if(f.open(IO_ReadOnly)) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd()) {
s=t.readLine();
if(s.left(4) == "File") {
s=s.right(s.length() - 6);
s.replace(QRegExp("%20")," ");
qDebug("adding "+s+" to playlist");
// numberofentries=2
// File1=http
// Title