1 /****************************************************************************************
2  * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>                         *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 #ifndef AMAROK_MEDIADEVICECACHE_H
18 #define AMAROK_MEDIADEVICECACHE_H
19 
20 #include "amarok_export.h"
21 
22 #include <QObject>
23 #include <QMap>
24 #include <QStringList>
25 
26 
27 class AMAROK_EXPORT MediaDeviceCache : public QObject
28 {
29     Q_OBJECT
30 
31     public:
32 
33         enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType };
34 
instance()35         static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); }
36 
37         /**
38         * Creates a new MediaDeviceCache.
39         *
40         */
41         MediaDeviceCache();
42         ~MediaDeviceCache() override;
43 
44         void refreshCache();
getAll()45         const QStringList getAll() const { return m_type.keys(); }
46         MediaDeviceCache::DeviceType deviceType( const QString &udi ) const;
47         const QString deviceName( const QString &udi ) const;
48         const QString device( const QString & udi ) const;
49         bool isGenericEnabled( const QString &udi ) const;
50         const QString volumeMountPoint( const QString &udi ) const;
51 
52     Q_SIGNALS:
53         void deviceAdded( const QString &udi );
54         void deviceRemoved( const QString &udi );
55         void accessibilityChanged( bool accessible, const QString &udi );
56 
57     public Q_SLOTS:
58         void slotAddSolidDevice( const QString &udi );
59         void slotRemoveSolidDevice( const QString &udi );
60         void slotAccessibilityChanged( bool accessible, const QString &udi );
61 
62     private:
63         QMap<QString, MediaDeviceCache::DeviceType> m_type;
64         QMap<QString, QString> m_name;
65         QMap<QString, bool> m_accessibility;
66         QStringList m_volumes;
67         static MediaDeviceCache* s_instance;
68 };
69 
70 #endif /* AMAROK_MEDIADEVICECACHE_H */
71 
72