strawberry-audio-player-win.../src/core/musicstorage.h

109 lines
3.0 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
2021-03-20 21:14:47 +01:00
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
2018-02-27 18:06:05 +01:00
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
#ifndef MUSICSTORAGE_H
#define MUSICSTORAGE_H
#include "config.h"
2020-02-08 03:40:30 +01:00
#include <QtGlobal>
2018-02-27 18:06:05 +01:00
#include <functional>
#include <memory>
#include <optional>
2018-02-27 18:06:05 +01:00
#include <QMetaType>
#include <QString>
#include <QList>
#include <QImage>
#include "shared_ptr.h"
#include "song.h"
2018-02-27 18:06:05 +01:00
class MusicStorage {
public:
2020-04-07 16:49:15 +02:00
explicit MusicStorage();
2020-06-15 21:55:05 +02:00
virtual ~MusicStorage() = default;
2018-02-27 18:06:05 +01:00
enum Role {
Role_Storage = Qt::UserRole + 100,
Role_StorageForceConnect,
Role_Capacity,
Role_FreeSpace,
};
// Values are saved in the database - don't change
2023-02-18 14:09:27 +01:00
enum class TranscodeMode {
2018-02-27 18:06:05 +01:00
Transcode_Always = 1,
Transcode_Never = 2,
Transcode_Unsupported = 3,
};
2022-10-13 22:39:31 +02:00
using ProgressFunction = std::function<void(float progress)>;
2018-02-27 18:06:05 +01:00
struct CopyJob {
CopyJob() : overwrite_(false), remove_original_(false), albumcover_(false) {}
2018-02-27 18:06:05 +01:00
QString source_;
QString destination_;
Song metadata_;
bool overwrite_;
bool remove_original_;
bool albumcover_;
QString cover_source_;
QString cover_dest_;
QImage cover_image_;
2018-02-27 18:06:05 +01:00
ProgressFunction progress_;
QString playlist_;
2018-02-27 18:06:05 +01:00
};
struct DeleteJob {
DeleteJob() : use_trash_(false) {}
2018-02-27 18:06:05 +01:00
Song metadata_;
bool use_trash_;
2018-02-27 18:06:05 +01:00
};
2022-10-19 18:36:33 +02:00
virtual Song::Source source() const = 0;
2018-02-27 18:06:05 +01:00
virtual QString LocalPath() const { return QString(); }
virtual std::optional<int> collection_directory_id() const { return std::optional<int>(); }
2018-02-27 18:06:05 +01:00
2023-02-18 14:09:27 +01:00
virtual TranscodeMode GetTranscodeMode() const { return TranscodeMode::Transcode_Never; }
virtual Song::FileType GetTranscodeFormat() const { return Song::FileType::Unknown; }
2021-06-12 20:53:23 +02:00
virtual bool GetSupportedFiletypes(QList<Song::FileType> *ret) { Q_UNUSED(ret); return true; }
2018-02-27 18:06:05 +01:00
2021-06-12 20:53:23 +02:00
virtual bool StartCopy(QList<Song::FileType> *supported_types) { Q_UNUSED(supported_types); return true; }
virtual bool CopyToStorage(const CopyJob &job) = 0;
2019-09-15 20:27:32 +02:00
virtual void FinishCopy(bool success) { Q_UNUSED(success); }
2018-02-27 18:06:05 +01:00
virtual void StartDelete() {}
2021-06-12 20:53:23 +02:00
virtual bool DeleteFromStorage(const DeleteJob &job) = 0;
2019-09-15 20:27:32 +02:00
virtual void FinishDelete(bool success) { Q_UNUSED(success); }
2018-02-27 18:06:05 +01:00
virtual void Eject() {}
2021-06-20 19:04:08 +02:00
private:
Q_DISABLE_COPY(MusicStorage)
2018-02-27 18:06:05 +01:00
};
2019-09-15 20:27:32 +02:00
Q_DECLARE_METATYPE(MusicStorage*)
Q_DECLARE_METATYPE(SharedPtr<MusicStorage>)
2018-02-27 18:06:05 +01:00
#endif // MUSICSTORAGE_H