diff document/SVFileReader.cpp @ 87:8944f3005a15

* Cancel when downloading file * Handle status codes (404 etc) * Add RemoteFile::isAvailable * Start on FileFinder for looking up files referred to in distant sessions
author Chris Cannam
date Wed, 10 Jan 2007 17:26:39 +0000
parents 41c491657587
children 51be0daa1386
line wrap: on
line diff
--- a/document/SVFileReader.cpp	Wed Jan 10 12:27:55 2007 +0000
+++ b/document/SVFileReader.cpp	Wed Jan 10 17:26:39 2007 +0000
@@ -21,6 +21,8 @@
 #include "base/PlayParameterRepository.h"
 
 #include "data/fileio/AudioFileReaderFactory.h"
+#include "data/fileio/FileFinder.h"
+#include "data/fileio/RemoteFile.h"
 
 #include "data/model/WaveFileModel.h"
 #include "data/model/EditableDenseThreeDimensionalModel.h"
@@ -147,9 +149,11 @@
 
 
 SVFileReader::SVFileReader(Document *document,
-			   SVFileReaderPaneCallback &callback) :
+			   SVFileReaderPaneCallback &callback,
+                           QString location) :
     m_document(document),
     m_paneCallback(callback),
+    m_location(location),
     m_currentPane(0),
     m_currentDataset(0),
     m_currentDerivedModel(0),
@@ -494,6 +498,36 @@
 
     if (type == "wavefile") {
 	
+        WaveFileModel *model = 0;
+        FileFinder finder(attributes.value("file"), m_location);
+        QString path = finder.getLocation();
+        QUrl url(path);
+
+        if (RemoteFile::canHandleScheme(url)) {
+
+            RemoteFile rf(url);
+            rf.wait();
+
+            if (rf.isOK()) {
+                model = new WaveFileModel(rf.getLocalFilename());
+                if (!model->isOK()) {
+                    delete model;
+                    model = 0;
+                    //!!! and delete local file?
+                }
+            }
+        } else {
+
+            model = new WaveFileModel(path);
+            if (!model->isOK()) {
+                delete model;
+                model = 0;
+            }
+        }
+
+        if (!model) return false;
+
+/*
 	QString file = attributes.value("file");
 	WaveFileModel *model = new WaveFileModel(file);
 
@@ -522,6 +556,7 @@
 		return false;
 	    }
 	}
+*/
 
 	m_models[id] = model;
 	if (mainModel) {