1 /* 2 * Cantata 3 * 4 * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com> 5 * 6 * ---- 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 */ 23 24 #ifndef DEVICE_OPTIONS_H 25 #define DEVICE_OPTIONS_H 26 27 #include <QString> 28 #include "config.h" 29 #ifdef ENABLE_DEVICES_SUPPORT 30 #include "encoders.h" 31 #endif 32 33 struct Song; 34 35 struct DeviceStorage { DeviceStorageDeviceStorage36 DeviceStorage() : size(0), used(0) { } freeSpaceDeviceStorage37 qulonglong freeSpace() const { return size-used; } 38 qulonglong size; 39 qulonglong used; 40 QString description; 41 QString volumeIdentifier; 42 }; 43 44 struct DeviceOptions { 45 enum TranscodeWhen { 46 TW_Always = 0, 47 TW_IfDifferent = 1, 48 TW_IfLossess = 2 49 }; 50 51 static const QLatin1String constAlbumArtist; 52 static const QLatin1String constComposer; 53 static const QLatin1String constAlbumTitle; 54 static const QLatin1String constTrackArtist; 55 static const QLatin1String constTrackTitle; 56 static const QLatin1String constTrackArtistAndTitle; 57 static const QLatin1String constTrackNumber; 58 static const QLatin1String constCdNumber; 59 static const QLatin1String constGenre; 60 static const QLatin1String constYear; 61 62 static bool isConfigured(const QString &group, bool isMpd=false); 63 64 #ifdef ENABLE_DEVICES_SUPPORT 65 DeviceOptions(const QString &cvrName=QString()); 66 #else 67 DeviceOptions(); 68 #endif 69 70 void load(const QString &group, bool isMpd=false); 71 void save(const QString &group, bool isMpd=false, bool saveTrans=true, bool saveFileNameScheme=true) const; 72 73 bool operator==(const DeviceOptions &o) const { 74 return vfatSafe==o.vfatSafe && asciiOnly==o.asciiOnly && ignoreThe==o.ignoreThe && 75 replaceSpaces==o.replaceSpaces && scheme==o.scheme 76 #ifdef ENABLE_DEVICES_SUPPORT 77 && coverMaxSize==o.coverMaxSize && coverName==o.coverName && name==o.name 78 && fixVariousArtists==o.fixVariousArtists && useCache==o.useCache && 79 transcoderCodec==o.transcoderCodec && autoScan==o.autoScan && volumeId==o.volumeId && 80 (transcoderCodec.isEmpty() || 81 (transcoderValue==o.transcoderValue && transcoderWhen==o.transcoderWhen)) 82 #endif 83 ; 84 } 85 bool operator!=(const DeviceOptions &o) const { return !(*this==o); } 86 QString clean(const QString &str) const; 87 Song clean(const Song &s) const; 88 QString createFilename(const Song &s) const; 89 #ifdef ENABLE_DEVICES_SUPPORT checkCoverSizeDeviceOptions90 void checkCoverSize() { 91 if (0==coverMaxSize || coverMaxSize>400) { 92 coverMaxSize=0; 93 } else { 94 coverMaxSize=((unsigned int)(coverMaxSize/100))*100; 95 } 96 } 97 #endif 98 QString scheme; 99 bool vfatSafe; 100 bool asciiOnly; 101 bool ignoreThe; 102 bool replaceSpaces; 103 #ifdef ENABLE_DEVICES_SUPPORT 104 bool fixVariousArtists; 105 QString transcoderCodec; 106 int transcoderValue; 107 TranscodeWhen transcoderWhen; 108 bool useCache; 109 bool autoScan; 110 QString name; 111 QString coverName; 112 unsigned int coverMaxSize; 113 QString volumeId; 114 #endif 115 }; 116 117 #endif 118