Chris@465: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@465: 
Chris@465: /*
Chris@465:     Sonic Visualiser
Chris@465:     An audio file viewer and annotation editor.
Chris@465:     Centre for Digital Music, Queen Mary, University of London.
Chris@465:     This file copyright 2008 QMUL.
Chris@465:     
Chris@465:     This program is free software; you can redistribute it and/or
Chris@465:     modify it under the terms of the GNU General Public License as
Chris@465:     published by the Free Software Foundation; either version 2 of the
Chris@465:     License, or (at your option) any later version.  See the file
Chris@465:     COPYING included with this distribution for more information.
Chris@465: */
Chris@465: 
Chris@465: #ifndef _CACHED_FILE_H_
Chris@465: #define _CACHED_FILE_H_
Chris@465: 
Chris@465: #include <QString>
Chris@465: #include <QUrl>
Chris@465: #include <QDateTime>
Chris@481: #include <map>
Chris@465: 
Chris@465: class ProgressReporter;
Chris@465: 
Chris@465: class CachedFile
Chris@465: {
Chris@465: public:
Chris@520:     CachedFile(QString fileOrUrl,
Chris@520:                ProgressReporter *reporter = 0,
Chris@520:                QString preferredContentType = "");
Chris@520:     CachedFile(QUrl url,
Chris@520:                ProgressReporter *reporter = 0,
Chris@520:                QString preferredContentType = "");
Chris@465: 
Chris@465:     virtual ~CachedFile();
Chris@465: 
Chris@465:     bool isOK() const;
Chris@465: 
Chris@465:     QString getLocalFilename() const;
Chris@465: 
Chris@465: protected:
Chris@468:     QString m_origin;
Chris@465:     QString m_localFilename;
Chris@520:     QString m_preferredContentType;
Chris@466:     ProgressReporter *m_reporter;
Chris@465:     bool m_ok;
Chris@465: 
Chris@691:     void checkFile();
Chris@465:     bool retrieve();
Chris@465: 
Chris@465:     QDateTime getLastRetrieval();
Chris@465:     void updateLastRetrieval(bool successful);
Chris@465: 
Chris@465:     static QString getCacheDirectory();
Chris@465:     static QString getLocalFilenameFor(QUrl url);
Chris@481: 
Chris@481:     typedef std::map<QString, QString> OriginLocalFilenameMap;
Chris@481:     static OriginLocalFilenameMap m_knownGoodCaches;
Chris@465: };
Chris@465: 
Chris@465: #endif