summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-16 19:23:12 (UTC)
committer llornkcor <llornkcor>2002-06-16 19:23:12 (UTC)
commit1eca76c99326afc111efeb2bf55a306a4f37eb1e (patch) (unidiff)
treea46c4c7d373688300cafc254a1e0ca9de508609e
parentb1d106338eca0c28573e2fc83c63c8ed3c76a239 (diff)
downloadopie-1eca76c99326afc111efeb2bf55a306a4f37eb1e.zip
opie-1eca76c99326afc111efeb2bf55a306a4f37eb1e.tar.gz
opie-1eca76c99326afc111efeb2bf55a306a4f37eb1e.tar.bz2
lame attempt to deal with illegal urls
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index d7447b7..200ec16 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1035,49 +1035,51 @@ void PlayListWidget::populateVideoView() {
1035 for( ; it.current(); ++it ){ 1035 for( ; it.current(); ++it ){
1036 const QString name = (*it)->name(); 1036 const QString name = (*it)->name();
1037 const QString path = (*it)->path(); 1037 const QString path = (*it)->path();
1038 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1038 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1039 } 1039 }
1040 1040
1041 QListViewItem * newItem; 1041 QListViewItem * newItem;
1042 if ( QFile( Vdit.current()->file()).exists() ) { 1042 if ( QFile( Vdit.current()->file()).exists() ) {
1043 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1043 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1044 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1044 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1045 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1045 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1046 } 1046 }
1047 } 1047 }
1048} 1048}
1049 1049
1050void PlayListWidget::openFile() { 1050void PlayListWidget::openFile() {
1051 QString filename, name; 1051 QString filename, name;
1052 InputDialog *fileDlg; 1052 InputDialog *fileDlg;
1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1054 fileDlg->exec(); 1054 fileDlg->exec();
1055 if( fileDlg->result() == 1 ) { 1055 if( fileDlg->result() == 1 ) {
1056 filename = fileDlg->LineEdit1->text(); 1056 filename = fileDlg->LineEdit1->text();
1057// http://205.188.234.129:8030 1057// http://205.188.234.129:8030
1058// http://66.28.68.70:8000 1058// http://66.28.68.70:8000
1059 qDebug("Selected filename is "+filename); 1059 filename.replace(QRegExp("%20")," ");
1060
1061 qDebug("Selected filename is "+filename);
1060 if(filename.right(3) == "m3u") 1062 if(filename.right(3) == "m3u")
1061 readm3u( filename); 1063 readm3u( filename);
1062 else if(filename.right(3) == "pls") 1064 else if(filename.right(3) == "pls")
1063 readPls( filename); 1065 readPls( filename);
1064 else { 1066 else {
1065 DocLnk lnk; 1067 DocLnk lnk;
1066 1068
1067 lnk.setName(filename); //sets file name 1069 lnk.setName(filename); //sets file name
1068 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1070 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1069 filename += "/"; 1071 filename += "/";
1070 lnk.setFile(filename); //sets File property 1072 lnk.setFile(filename); //sets File property
1071 1073
1072 lnk.setType("audio/x-mpegurl"); 1074 lnk.setType("audio/x-mpegurl");
1073 lnk.setExec("opieplayer"); 1075 lnk.setExec("opieplayer");
1074 lnk.setIcon("opieplayer/MPEGPlayer"); 1076 lnk.setIcon("opieplayer/MPEGPlayer");
1075 1077
1076 if(!lnk.writeLink()) 1078 if(!lnk.writeLink())
1077 qDebug("Writing doclink did not work"); 1079 qDebug("Writing doclink did not work");
1078 d->selectedFiles->addToSelection( lnk); 1080 d->selectedFiles->addToSelection( lnk);
1079// if(fileDlg2) 1081// if(fileDlg2)
1080// delete fileDlg2; 1082// delete fileDlg2;
1081 } 1083 }
1082 } 1084 }
1083 if(fileDlg) 1085 if(fileDlg)
@@ -1185,84 +1187,86 @@ void PlayListWidget::readm3u(const QString &filename) {
1185 QFile f(filename); 1187 QFile f(filename);
1186 1188
1187 if(f.open(IO_ReadOnly)) { 1189 if(f.open(IO_ReadOnly)) {
1188 QTextStream t(&f); 1190 QTextStream t(&f);
1189 QString s;//, first, second; 1191 QString s;//, first, second;
1190 int i=0; 1192 int i=0;
1191 while ( !t.atEnd()) { 1193 while ( !t.atEnd()) {
1192// Lview->insertLine(t.readLine(),-1); 1194// Lview->insertLine(t.readLine(),-1);
1193 s=t.readLine(); 1195 s=t.readLine();
1194 if(s.find("#",0,TRUE) == -1) { 1196 if(s.find("#",0,TRUE) == -1) {
1195 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1197 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1196 if(s.left(2) == "E:" || s.left(2) == "P:") { 1198 if(s.left(2) == "E:" || s.left(2) == "P:") {
1197 s=s.right(s.length()-2); 1199 s=s.right(s.length()-2);
1198 DocLnk lnk( s ); 1200 DocLnk lnk( s );
1199 QFileInfo f(s); 1201 QFileInfo f(s);
1200 QString name = f.baseName(); 1202 QString name = f.baseName();
1201 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1203 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1202 lnk.setName( name); 1204 lnk.setName( name);
1203 s=s.replace( QRegExp("\\"),"/"); 1205 s=s.replace( QRegExp("\\"),"/");
1204 lnk.setFile( s); 1206 lnk.setFile( s);
1205// lnk.setIcon(opieplayer/MPEGPlayer); 1207// lnk.setIcon(opieplayer/MPEGPlayer);
1206 qDebug("add "+name); 1208 qDebug("add "+name);
1207 d->selectedFiles->addToSelection( lnk); 1209 d->selectedFiles->addToSelection( lnk);
1208 } else { // is url 1210 } else { // is url
1211 s.replace(QRegExp("%20")," ");
1209 DocLnk lnk( s); 1212 DocLnk lnk( s);
1210 QString name = s.right( s.length() - 7); 1213 QString name = s.right( s.length() - 7);
1211// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1214// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1212 lnk.setName(name); 1215 lnk.setName(name);
1213 lnk.setFile( s+"/"); 1216 lnk.setFile( s+"/");
1214// lnk.setFile( filename); 1217// lnk.setFile( filename);
1215// lnk.setComment( s+"/"); 1218// lnk.setComment( s+"/");
1216 lnk.setType("audio/x-mpegurl"); 1219 lnk.setType("audio/x-mpegurl");
1217// lnk.setIcon( "opieplayer/MPEGPlayer"); 1220// lnk.setIcon( "opieplayer/MPEGPlayer");
1218// qDebug("add "+s); 1221// qDebug("add "+s);
1219 d->selectedFiles->addToSelection( lnk); 1222 d->selectedFiles->addToSelection( lnk);
1220 } 1223 }
1221 i++; 1224 i++;
1222 } 1225 }
1223 } 1226 }
1224 } 1227 }
1225 } 1228 }
1226} 1229}
1227 1230
1228void PlayListWidget::writem3u(const QString &filename) { 1231void PlayListWidget::writem3u(const QString &filename) {
1229 1232
1230} 1233}
1231 1234
1232void PlayListWidget::readPls(const QString &filename) { 1235void PlayListWidget::readPls(const QString &filename) {
1233 1236
1234 qDebug("pls filename is "+filename); 1237 qDebug("pls filename is "+filename);
1235 QFile f(filename); 1238 QFile f(filename);
1236 1239
1237 if(f.open(IO_ReadOnly)) { 1240 if(f.open(IO_ReadOnly)) {
1238 QTextStream t(&f); 1241 QTextStream t(&f);
1239 QString s;//, first, second; 1242 QString s;//, first, second;
1240 int i=0; 1243 int i=0;
1241 while ( !t.atEnd()) { 1244 while ( !t.atEnd()) {
1242 s=t.readLine(); 1245 s=t.readLine();
1243 if(s.left(4) == "File") { 1246 if(s.left(4) == "File") {
1244 s=s.right(s.length() - 6); 1247 s=s.right(s.length() - 6);
1248 s.replace(QRegExp("%20")," ");
1245 qDebug("adding "+s+" to playlist"); 1249 qDebug("adding "+s+" to playlist");
1246// numberofentries=2 1250// numberofentries=2
1247// File1=http 1251// File1=http
1248 // Title 1252 // Title
1249// Length 1253// Length
1250// Version 1254// Version
1251// File2=http 1255// File2=http
1252 1256
1253 s=s.replace( QRegExp("\\"),"/"); 1257 s=s.replace( QRegExp("\\"),"/");
1254// Lview->insertLine(t.readLine(),-1); 1258// Lview->insertLine(t.readLine(),-1);
1255// s=t.readLine(); 1259// s=t.readLine();
1256// s=s.right(s.length()-2); 1260// s=s.right(s.length()-2);
1257 DocLnk lnk( s ); 1261 DocLnk lnk( s );
1258 QFileInfo f(s); 1262 QFileInfo f(s);
1259 QString name = f.baseName(); 1263 QString name = f.baseName();
1260 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1264 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1261// QFileInfo f(s); 1265// QFileInfo f(s);
1262// QString name = f.baseName(); 1266// QString name = f.baseName();
1263// // name = name.left(name.length()-4); 1267// // name = name.left(name.length()-4);
1264// name = name.right(name.findRev("/",0,TRUE)); 1268// name = name.right(name.findRev("/",0,TRUE));
1265 lnk.setName( name); 1269 lnk.setName( name);
1266 lnk.setFile( s+"/"); 1270 lnk.setFile( s+"/");
1267 lnk.setType("audio/x-mpegurl"); 1271 lnk.setType("audio/x-mpegurl");
1268 1272