File indexing completed on 2024-04-21 04:47:52
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.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 AMAROK_MEDIADEVICECACHE_H 0018 #define AMAROK_MEDIADEVICECACHE_H 0019 0020 #include "amarok_export.h" 0021 0022 #include <QObject> 0023 #include <QMap> 0024 #include <QStringList> 0025 0026 0027 class AMAROK_EXPORT MediaDeviceCache : public QObject 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 0033 enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType }; 0034 0035 static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); } 0036 0037 /** 0038 * Creates a new MediaDeviceCache. 0039 * 0040 */ 0041 MediaDeviceCache(); 0042 ~MediaDeviceCache() override; 0043 0044 void refreshCache(); 0045 const QStringList getAll() const { return m_type.keys(); } 0046 MediaDeviceCache::DeviceType deviceType( const QString &udi ) const; 0047 const QString deviceName( const QString &udi ) const; 0048 const QString device( const QString & udi ) const; 0049 bool isGenericEnabled( const QString &udi ) const; 0050 const QString volumeMountPoint( const QString &udi ) const; 0051 0052 Q_SIGNALS: 0053 void deviceAdded( const QString &udi ); 0054 void deviceRemoved( const QString &udi ); 0055 void accessibilityChanged( bool accessible, const QString &udi ); 0056 0057 public Q_SLOTS: 0058 void slotAddSolidDevice( const QString &udi ); 0059 void slotRemoveSolidDevice( const QString &udi ); 0060 void slotAccessibilityChanged( bool accessible, const QString &udi ); 0061 0062 private: 0063 QMap<QString, MediaDeviceCache::DeviceType> m_type; 0064 QMap<QString, QString> m_name; 0065 QMap<QString, bool> m_accessibility; 0066 QStringList m_volumes; 0067 static MediaDeviceCache* s_instance; 0068 }; 0069 0070 #endif /* AMAROK_MEDIADEVICECACHE_H */ 0071