File indexing completed on 2025-01-19 04:24:29
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Alejandro Wainzinger <aikawarazuni@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef MEDIADEVICEHANDLER_WRITECAPABILITY_H 0018 #define MEDIADEVICEHANDLER_WRITECAPABILITY_H 0019 0020 #include "core-impl/collections/mediadevicecollection/MediaDeviceMeta.h" 0021 #include "core-impl/collections/mediadevicecollection/handler/MediaDeviceHandlerCapability.h" 0022 #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h" 0023 0024 namespace Handler 0025 { 0026 0027 class MEDIADEVICECOLLECTION_EXPORT WriteCapability : public Handler::Capability 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit WriteCapability( QObject *parent ) : Capability( parent ) {} 0033 ~WriteCapability() override; 0034 0035 static Type capabilityInterfaceType() { return Handler::Capability::Writable; } 0036 0037 /** 0038 * Returns a list of formats supported by the device, all in lowercase 0039 * For example mp3, mpeg, aac. This is used to avoid copying unsupported 0040 * types to a particular device. 0041 */ 0042 virtual QStringList supportedFormats() = 0; // md:write 0043 0044 /** 0045 * Finds the place to copy the track to on the device, which 0046 * could be a url in the case of Ipods, or a folder in the 0047 * case of MTP devices. 0048 * @param srcTrack The source track of the copy 0049 * @param destTrack The destination track whose path we seek 0050 */ 0051 virtual void findPathToCopy( const Meta::TrackPtr &srcTrack, const Meta::MediaDeviceTrackPtr &destTrack ) = 0; 0052 0053 /** 0054 * libCopyTrack does the actual file copying. For Ipods, it uses KIO, 0055 * for MTPs this uses a libmtp call 0056 * Copy the file associate with srcTrack to destTrack 0057 * @param srcTrack The track being copied from 0058 * @param destTrack The track being copied to 0059 * @return Whether or not the track copy was successful 0060 */ 0061 virtual bool libCopyTrack( const Meta::TrackPtr &srcTrack, Meta::MediaDeviceTrackPtr &destTrack ) = 0; 0062 0063 /** 0064 * libDeleteTrack does the actual file deleting. For Ipods, it uses KIO, 0065 * for MTPs this uses a libmtp call. Must Q_EMIT libRemoveTrackDone when finished. 0066 * @param track The track whose file is to be deleted 0067 * @return Whether or not the track removal was successful 0068 */ 0069 virtual bool libDeleteTrackFile( const Meta::MediaDeviceTrackPtr &track ) = 0; 0070 0071 /** 0072 * This function is called just before copying tracks begin and allows 0073 * a subclass to prepare to copy, e.g. for Ipods it would initialize 0074 * the job counter to 0. 0075 */ 0076 virtual void prepareToCopy() = 0; 0077 0078 /** 0079 * This function is called just before deleting tracks begin and allows 0080 * a subclass to prepare to delete, e.g. for Ipods it would initialize 0081 * the m_tracksdeleting to keep track of urls it is deleting. 0082 */ 0083 virtual void prepareToDelete() = 0; 0084 0085 /** 0086 * Tells subclass that it can update the track, usually because 0087 * the track's tags have changed. 0088 * @param track The track whose tags should be updated 0089 */ 0090 virtual void updateTrack( Meta::MediaDeviceTrackPtr &track ) 0091 { 0092 Q_UNUSED( track ) 0093 } 0094 0095 /** 0096 * Creates a new track struct particular to the library of the device 0097 * e.g. LIBMTP_new_track_t(), and associates it with the track for 0098 * later use, in the same way that setAssociateTrack does it. 0099 * @param track The track for which to create a track struct and associate it to 0100 */ 0101 virtual void libCreateTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; 0102 0103 /** 0104 * Deletes the track struct associated with this track, freeing 0105 * any memory it occupied, and dissociating it from the track 0106 * @param track The track whose associated track struct is to be deleted. 0107 */ 0108 virtual void libDeleteTrack( const Meta::MediaDeviceTrackPtr &track ) = 0; 0109 0110 /** 0111 * Adds the newly created track struct now populated with info into the 0112 * database struct of the particular device, e.g. into the itdb for Ipods. 0113 * MTP devices automatically add the track into the database upon copying, 0114 * so MTP would do nothing. 0115 * @param track The track whose associated track struct is to be added 0116 * into the database. 0117 */ 0118 virtual void addTrackInDB( const Meta::MediaDeviceTrackPtr &track ) = 0; 0119 0120 /** 0121 * Remove all traces of the track struct associated with @param track from 0122 * the database struct, but do not delete the struct 0123 * @param track The track whose associated track struct is to be removed 0124 * from the database. 0125 */ 0126 virtual void removeTrackFromDB( const Meta::MediaDeviceTrackPtr &track ) = 0; 0127 0128 /** 0129 * Indicates to the subclass that the database has been updated 0130 */ 0131 virtual void setDatabaseChanged() = 0; 0132 0133 /* 0134 * Each libSet function sets the private track struct associated with @param track 0135 * to the second value passed into the function. 0136 */ 0137 0138 virtual void libSetTitle( Meta::MediaDeviceTrackPtr &track, const QString& title ) = 0; 0139 virtual void libSetAlbum( Meta::MediaDeviceTrackPtr &track, const QString& album ) = 0; 0140 virtual void libSetArtist( Meta::MediaDeviceTrackPtr &track, const QString& artist ) = 0; 0141 virtual void libSetAlbumArtist( Meta::MediaDeviceTrackPtr &track, const QString& albumArtist ) = 0; 0142 virtual void libSetComposer( Meta::MediaDeviceTrackPtr &track, const QString& composer ) = 0; 0143 virtual void libSetGenre( Meta::MediaDeviceTrackPtr &track, const QString& genre ) = 0; 0144 virtual void libSetYear( Meta::MediaDeviceTrackPtr &track, const QString& year ) = 0; 0145 virtual void libSetLength( Meta::MediaDeviceTrackPtr &track, int length ) = 0; 0146 virtual void libSetTrackNumber( Meta::MediaDeviceTrackPtr &track, int tracknum ) = 0; 0147 virtual void libSetComment( Meta::MediaDeviceTrackPtr &track, const QString& comment ) = 0; 0148 virtual void libSetDiscNumber( Meta::MediaDeviceTrackPtr &track, int discnum ) = 0; 0149 virtual void libSetBitrate( Meta::MediaDeviceTrackPtr &track, int bitrate ) = 0; 0150 virtual void libSetSamplerate( Meta::MediaDeviceTrackPtr &track, int samplerate ) = 0; 0151 virtual void libSetBpm( Meta::MediaDeviceTrackPtr &track, qreal bpm ) = 0; 0152 virtual void libSetFileSize( Meta::MediaDeviceTrackPtr &track, int filesize ) = 0; 0153 virtual void libSetPlayCount( Meta::MediaDeviceTrackPtr &track, int playcount ) = 0; 0154 virtual void libSetLastPlayed( Meta::MediaDeviceTrackPtr &track, const QDateTime &lastplayed ) = 0; 0155 virtual void libSetRating( Meta::MediaDeviceTrackPtr &track, int rating ) = 0; 0156 virtual void libSetType( Meta::MediaDeviceTrackPtr &track, const QString& type ) = 0; 0157 virtual void libSetPlayableUrl( Meta::MediaDeviceTrackPtr &destTrack, const Meta::TrackPtr &srcTrack ) = 0; 0158 virtual void libSetIsCompilation( Meta::MediaDeviceTrackPtr &track, bool isCompilation ); 0159 virtual void libSetReplayGain( Meta::MediaDeviceTrackPtr &track, qreal newReplayGain ); 0160 virtual void libSetCoverArt( Meta::MediaDeviceTrackPtr &track, const QImage &cover ) = 0; 0161 }; 0162 } 0163 0164 #endif