File indexing completed on 2025-01-19 04:24:22
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com> * 0003 * Copyright (c) 2007 Casey Link <unnamedrambler@gmail.com> * 0004 * Copyright (c) 2013 Ralf Engels <ralf-engels@gmx.de> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #ifndef AMAROK_COLLECTION_SQLCOLLECTION_H 0020 #define AMAROK_COLLECTION_SQLCOLLECTION_H 0021 0022 #include "amarok_sqlcollection_export.h" 0023 #include "core/capabilities/TranscodeCapability.h" 0024 #include <core/storage/SqlStorage.h> 0025 #include <core-impl/collections/db/DatabaseCollection.h> 0026 #include "SqlRegistry.h" 0027 0028 #include <QSharedPointer> 0029 0030 class SqlScanResultProcessor; 0031 class AbstractDirectoryWatcher; 0032 0033 namespace Collections { 0034 0035 class CollectionLocation; 0036 class SqlCollectionLocationFactory; 0037 class SqlQueryMakerFactory; 0038 0039 /// Configuration group name in amarokrc for preferred transcoding configuration for SqlCollection 0040 static const QString SQL_TRANSCODING_GROUP_NAME = QStringLiteral("Collection Transcoding Preference"); 0041 0042 class AMAROK_SQLCOLLECTION_EXPORT SqlCollection : public Collections::DatabaseCollection 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 /** Creates a new SqlCollection. 0048 * @param storage The storage this collection should work on. It will be freed by the collection. 0049 */ 0050 explicit SqlCollection( const QSharedPointer<SqlStorage> &storage ); 0051 ~SqlCollection() override; 0052 0053 QueryMaker *queryMaker() override; 0054 0055 /** Returns the protocol for the uid urls of this collection. 0056 The SqlCollection support "amarok-sqltrackuid" and "file" protocol. 0057 */ 0058 QString uidUrlProtocol() const override; 0059 /** 0060 * Generates uidUrl out of a hash (as returned by tag reader) that can be then 0061 * fed to Track::setUidUrl(). 0062 */ 0063 QString generateUidUrl( const QString &hash ); 0064 0065 // Local collection cannot have a capacity since it may be spread over multiple 0066 // physical locations (even network components) 0067 0068 SqlRegistry* registry() const; 0069 QSharedPointer<SqlStorage> sqlStorage() const; 0070 0071 /** Every collection has this function. */ 0072 bool possiblyContainsTrack( const QUrl &url ) const override; 0073 0074 Meta::TrackPtr trackForUrl( const QUrl &url ) override; 0075 0076 /** Gets an existing track (or a new one) at the given position. 0077 This function should only be used by the SqlScanResultProcessor. */ 0078 virtual Meta::TrackPtr getTrack( int deviceId, const QString &rpath, int directoryId, const QString &uidUrl ); 0079 virtual Meta::TrackPtr getTrackFromUid( const QString &uniqueid ); 0080 virtual Meta::AlbumPtr getAlbum( const QString &album, const QString &artist ); 0081 0082 CollectionLocation* location() override; 0083 0084 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0085 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0086 0087 public Q_SLOTS: 0088 /** Dumps the complete database content. 0089 * The content of all Amarok tables is dumped in a couple of files 0090 * in the users homedirectory. 0091 */ 0092 void dumpDatabaseContent() override; 0093 0094 private Q_SLOTS: 0095 void slotDeviceAdded( int id ) override; 0096 void slotDeviceRemoved( int id ) override; 0097 0098 private: 0099 SqlRegistry* m_registry; 0100 QSharedPointer<SqlStorage> m_sqlStorage; 0101 0102 SqlScanResultProcessor* m_scanProcessor; 0103 QWeakPointer<AbstractDirectoryWatcher> m_directoryWatcher; 0104 0105 SqlCollectionLocationFactory* m_collectionLocationFactory; 0106 SqlQueryMakerFactory* m_queryMakerFactory; 0107 }; 0108 0109 class AMAROK_SQLCOLLECTION_EXPORT SqlCollectionTranscodeCapability : public Capabilities::TranscodeCapability 0110 { 0111 Q_OBJECT 0112 public: 0113 0114 ~SqlCollectionTranscodeCapability() override; 0115 0116 Transcoding::Configuration savedConfiguration() override; 0117 void setSavedConfiguration( const Transcoding::Configuration &configuration ) override; 0118 }; 0119 0120 } 0121 0122 #endif /* AMAROK_COLLECTION_SQLCOLLECTION_H */